new upstream 2.8.0

This commit is contained in:
lagertonne 2022-06-29 12:37:36 +02:00
parent fc7f4b43c1
commit b2b0c9995a
836 changed files with 137090 additions and 30018 deletions

View file

@ -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

View file

@ -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

View file

@ -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 <rkroll@exploits.org>
2005 Arnaud Quette <arnaud.quette@free.fr>
2020 Jim Klimov <jimklimov@gmail.com>
#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 */

View file

@ -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 <rkroll@exploits.org>
@ -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 <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h> /* for strncasecmp() and strcasecmp() */
#endif
#ifdef HAVE_STRING_H
#include <string.h> /* for strdup() and many others */
#endif
#include <syslog.h>
#include <unistd.h>
#include <assert.h>
@ -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 - <name> 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 <pidfn>, get the pid, then send it <sig> */
/* 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 <pidfn>, get the pid, then send it <sig>
* 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 */

View file

@ -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 <dlfcn.h> 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 <float.h>. */
#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 <libpowerman.h> 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 <libusb.h> 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 <limits.h>. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have <linux/i2c-dev.h>. */
#undef HAVE_LINUX_I2C_DEV_H
/* Define to 1 if you have <i2c/smbus.h>. */
#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 <ltdl.h> header file. */
#undef HAVE_LTDL_H
/* Define to 1 if you have <math.h>. */
#undef HAVE_MATH_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <modbus.h> 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 <netdb.h> header file. */
#undef HAVE_NETDB_H
/* Define to 1 if you have the <net-snmp/net-snmp-config.h> 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 <sys/semaphore.h> with usable sem_t sem_init() and
sem_destroy(). */
#undef HAVE_SEMAPHORE
/* Define to 1 if you have <sys/semaphore.h>. */
#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 <signal.h>. */
#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 <ssl.h> 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 <stdarg.h> header file. */
#undef HAVE_STDARG_H
@ -221,21 +644,46 @@
/* Define to 1 if you have the <stdlib.h> 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 <strings.h> header file. */
/* Define to 1 if you have <strings.h>. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
/* Define to 1 if you have <string.h>. */
#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 <sys/modem.h> header file. */
#undef HAVE_SYS_MODEM_H
/* Define to 1 if you have <sys/resource.h> with usable struct rlimit and
getrlimit(). */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have <sys/signal.h>. */
#undef HAVE_SYS_SIGNAL_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> 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 <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if you have the <unistd.h> 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 <sys/time.h> and <time.h>. */
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. 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

View file

@ -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 <rkroll@exploits.org>
2005 Arnaud Quette <arnaud.quette@free.fr>
2007 Peter Selinger <selinger@users.sourceforge.net>
2008 Arjen de Korte <adkorte-guest@alioth.debian.org>
2013 Emilien Kia <kiae.dev@gmail.com>
2020 Jim Klimov <jimklimov@gmail.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 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 */

54
include/nut_float.h Normal file
View file

@ -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 <jimklimov@gmail.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 NUT_FLOAT_H_SEEN
#define NUT_FLOAT_H_SEEN 1
#include "config.h"
#if defined HAVE_FLOAT_H
# include <float.h>
#endif
#if defined HAVE_MATH_H
# include <math.h>
#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 */

View file

@ -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 */

View file

@ -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 <inttypes.h>
#endif
@ -31,4 +39,33 @@
# include <stdint.h>
#endif
#if defined HAVE_LIMITS_H
# include <limits.h>
#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 */

View file

@ -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 */

View file

@ -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 <rkroll@exploits.org>
2005 Arnaud Quette <arnaud.quette@free.fr>
2006 Peter Selinger <selinger@users.sourceforge.net>
2013 Emilien Kia <kiae.dev@gmail.com>
2020 Jim Klimov <jimklimov@gmail.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 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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 <rkroll@exploits.org>
2005 Arnaud Quette <arnaud.quette@free.fr>
2020 Jim Klimov <jimklimov@gmail.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 NUT_TIMEHEAD_H_SEEN
#define NUT_TIMEHEAD_H_SEEN 1
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#endif /* NUT_TIMEHEAD_H_SEEN */

View file

@ -1,3 +1,27 @@
/* upsconf.h - prototypes for upsconf.c
Copyright (C) 2001 Russell Kroll <rkroll@exploits.org>
2005 Arnaud Quette <arnaud.quette@free.fr>
2013 Emilien Kia <kiae.dev@gmail.com>
2020 Jim Klimov <jimklimov@gmail.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 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 */