Imported Upstream version 2.4.3

This commit is contained in:
arnaud.quette@free.fr 2010-03-26 00:20:59 +01:00
commit 26fb71b504
446 changed files with 148951 additions and 0 deletions

25
include/Makefile.am Normal file
View file

@ -0,0 +1,25 @@
EXTRA_DIST = attribute.h common.h extstate.h parseconf.h proto.h \
state.h timehead.h upsconf.h
# http://www.gnu.org/software/automake/manual/automake.html#Clean
BUILT_SOURCES = nut_version.h nut_stdint.h
DISTCLEANFILES = nut_stdint.h
CLEANFILES = nut_version.h
# magic to include SVN revision number in NUT version string
nut_version.h: FORCE
@SVNREV=`LANG=C svnversion -n $(top_srcdir) 2>/dev/null`; \
if [ -z "$$SVNREV" -o "$$SVNREV" = "exported" ]; \
then NUT_VERSION="$(PACKAGE_VERSION)"; \
else NUT_VERSION="$(PACKAGE_VERSION)-$$SVNREV"; \
fi ; \
echo '/* Autogenerated file. Do not change. */' > _nut_version.h ; \
echo '/* This file was generated by "make". */' >> _nut_version.h ; \
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
FORCE:

460
include/Makefile.in Normal file
View file

@ -0,0 +1,460 @@
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@
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 = include
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/config.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_create_stdint_h.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_ipv6.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
$(top_srcdir)/m4/nut_check_libssl.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_report_feature.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BINDIR = @BINDIR@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFPATH = @CONFPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
HAL_FDI_PATH = @HAL_FDI_PATH@
HAL_USER = @HAL_USER@
HAVE_GLIB_2_14 = @HAVE_GLIB_2_14@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LDFLAGS = @LIBHAL_LDFLAGS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LDFLAGS = @LIBNEON_LDFLAGS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
LIBNETSNMP_LDFLAGS = @LIBNETSNMP_LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@
LIBPOWERMAN_LDFLAGS = @LIBPOWERMAN_LDFLAGS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LDFLAGS = @LIBSSL_LDFLAGS@
LIBTOOL = @LIBTOOL@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_LDFLAGS = @LIBUSB_LDFLAGS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LDFLAGS = @LIBWRAP_LDFLAGS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NM = @NM@
NMEDIT = @NMEDIT@
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@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
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@
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@
docdir = @docdir@
driverexecdir = @driverexecdir@
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@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
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 = attribute.h common.h extstate.h parseconf.h proto.h \
state.h timehead.h upsconf.h
# http://www.gnu.org/software/automake/manual/automake.html#Clean
BUILT_SOURCES = nut_version.h nut_stdint.h
DISTCLEANFILES = nut_stdint.h
CLEANFILES = nut_version.h
all: $(BUILT_SOURCES) config.h
$(MAKE) $(AM_MAKEFLAGS) 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 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);; \
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):
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status include/config.h
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(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: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile config.h
installdirs:
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) 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:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
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 "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr
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: all check install install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-hdr 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 \
uninstall uninstall-am
# magic to include SVN revision number in NUT version string
nut_version.h: FORCE
@SVNREV=`LANG=C svnversion -n $(top_srcdir) 2>/dev/null`; \
if [ -z "$$SVNREV" -o "$$SVNREV" = "exported" ]; \
then NUT_VERSION="$(PACKAGE_VERSION)"; \
else NUT_VERSION="$(PACKAGE_VERSION)-$$SVNREV"; \
fi ; \
echo '/* Autogenerated file. Do not change. */' > _nut_version.h ; \
echo '/* This file was generated by "make". */' >> _nut_version.h ; \
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
FORCE:
# 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:

12
include/attribute.h Normal file
View file

@ -0,0 +1,12 @@
/* portability hacks for __attribute__ usage in other header files */
#ifndef ATTRIBUTE_H_SEEN
#define ATTRIBUTE_H_SEEN 1
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
#endif
#endif /* ATTRIBUTE_H_SEEN */

145
include/common.h Normal file
View file

@ -0,0 +1,145 @@
#ifndef NUT_COMMON_H
#define NUT_COMMON_H
/* common.h - prototypes for the common useful functions
Copyright (C) 2000 Russell Kroll <rkroll@exploits.org>
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 the first header */
/* Need this on AIX when using xlc to get alloca */
#ifdef _AIX
#pragma alloca
#endif /* _AIX */
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <assert.h>
#include "timehead.h"
#include "attribute.h"
#include "proto.h"
extern const char *UPS_VERSION;
/* get the syslog ready for us */
void open_syslog(const char *progname);
/* close ttys and become a daemon */
void background(void);
/* do this here to keep pwd/grp stuff out of the main files */
struct passwd *get_user_pwent(const char *name);
/* change to the user defined in the struct */
void become_user(struct passwd *pw);
/* drop down into a directory and throw away pointers to the old path */
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);
/* 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> */
int sendsignalfn(const char *pidfn, int sig);
const char *xbasename(const char *file);
/* enable writing upslog_with_errno() and upslogx() type messages to
the syslog */
void syslogbit_set(void);
/* Return the default path for the directory containing configuration files */
const char * confpath(void);
/* Return the default path for the directory containing state files */
const char * dflt_statepath(void);
/* Return the alternate path for pid files */
const char * altpidpath(void);
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, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
void 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 fatal_with_errno(int status, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3))) __attribute__((noreturn));
void fatalx(int status, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3))) __attribute__((noreturn));
extern int nut_debug_level;
void *xmalloc(size_t size);
void *xcalloc(size_t number, size_t size);
void *xrealloc(void *ptr, size_t size);
char *xstrdup(const char *string);
char *rtrim(char *in, const char sep);
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);
/* Buffer sizes used for various functions */
#define SMALLBUF 512
#define LARGEBUF 1024
/* Provide declarations for getopt() global variables */
#ifdef NEED_GETOPT_H
#include <getopt.h>
#else
#ifdef NEED_GETOPT_DECLS
extern char *optarg;
extern int optind;
#endif /* NEED_GETOPT_DECLS */
#endif /* HAVE_GETOPT_H */
/* logging flags: bitmask! */
#define UPSLOG_STDERR 0x0001
#define UPSLOG_SYSLOG 0x0002
#define UPSLOG_STDERR_ON_FATAL 0x0004
#define UPSLOG_SYSLOG_ON_FATAL 0x0008
#ifndef HAVE_SETEUID
# define seteuid(x) setresuid(-1,x,-1) /* Works for HP-UX 10.20 */
# define setegid(x) setresgid(-1,x,-1) /* Works for HP-UX 10.20 */
#endif
#endif /* NUT_COMMON_H */

389
include/config.h.in Normal file
View file

@ -0,0 +1,389 @@
/* include/config.h.in. Generated from configure.in by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Path for pid files of drivers and upsd (usually STATEPATH) */
#undef ALTPIDPATH
/* Default path for user executables */
#undef BINDIR
/* Default path for CGI programs */
#undef CGIPATH
/* Default path for configuration files */
#undef CONFPATH
/* Default path for data files */
#undef DATADIR
/* Default path for UPS drivers */
#undef DRVPATH
/* Define to nothing if C supports flexible array members, and to 1 if it does
not. That way, with a declaration like `struct s { int n; double
d[FLEXIBLE_ARRAY_MEMBER]; };', the struct hack can be used with pre-C99
compilers. When computing the size of such an object, don't use 'sizeof
(struct s)' as it overestimates the size. Use 'offsetof (struct s, d)'
instead. Don't use 'offsetof (struct s, d[0])', as this doesn't work with
MSVC and with C++ compilers. */
#undef FLEXIBLE_ARRAY_MEMBER
/* HAL device match key */
#undef HAL_DEVICE_MATCH_KEY
/* HAL user */
#undef HAL_USER
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you have the `cfsetispeed' function. */
#undef HAVE_CFSETISPEED
/* Define to 1 if C supports variable-length arrays. */
#undef HAVE_C_VARARRAYS
/* Define to 1 if you have the declaration of `optind', and to 0 if you don't.
*/
#undef HAVE_DECL_OPTIND
/* Define to 1 if you have the declaration of `uu_lock', and to 0 if you
don't. */
#undef HAVE_DECL_UU_LOCK
/* Define to 1 if you have the declaration of `__FUNCTION__', and to 0 if you
don't. */
#undef HAVE_DECL___FUNCTION__
/* Define to 1 if you have the declaration of `__func__', and to 0 if you
don't. */
#undef HAVE_DECL___FUNC__
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* 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 `flock' function. */
#undef HAVE_FLOCK
/* Define to 1 if you have the `freeaddrinfo' function. */
#undef HAVE_FREEADDRINFO
/* Define to 1 if you have the <gdfontmb.h> header file. */
#undef HAVE_GDFONTMB_H
/* Define to 1 if you have the <gd.h> header file. */
#undef HAVE_GD_H
/* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the `getpassphrase' function. */
#undef HAVE_GETPASSPHRASE
/* Define to 1 if GLib is version 2.14 or newer */
#undef HAVE_GLIB_2_14
/* Define to 1 if you have the `inet_aton' function. */
#undef HAVE_INET_ATON
/* Define to 1 if you have the `init_snmp' function. */
#undef HAVE_INIT_SNMP
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to enable IPv6 support */
#undef HAVE_IPV6
/* Define if you have Boutell's libgd installed */
#undef HAVE_LIBGD
/* Define to 1 if you have the `libhal_device_new_changeset' function. */
#undef HAVE_LIBHAL_DEVICE_NEW_CHANGESET
/* Define to 1 if you have the <libhal.h> header file. */
#undef HAVE_LIBHAL_H
/* Define to 1 if you have the <libpowerman.h> header file. */
#undef HAVE_LIBPOWERMAN_H
/* 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'. */
#undef HAVE_LONG_LONG_INT
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <net-snmp/net-snmp-config.h> header file. */
#undef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
/* Define to 1 if you have the `ne_set_connect_timeout' function. */
#undef HAVE_NE_SET_CONNECT_TIMEOUT
/* Define to 1 if you have the `ne_sock_connect_timeout' function. */
#undef HAVE_NE_SOCK_CONNECT_TIMEOUT
/* Define to 1 if you have the <ne_xmlreq.h> header file. */
#undef HAVE_NE_XMLREQ_H
/* Define to 1 if you have the `ne_xml_dispatch_request' function. */
#undef HAVE_NE_XML_DISPATCH_REQUEST
/* Define to 1 if you have the `on_exit' function. */
#undef HAVE_ON_EXIT
/* Define to 1 if you have the <openssl/ssl.h> header file. */
#undef HAVE_OPENSSL_SSL_H
/* Define to 1 if you have the `pm_connect' function. */
#undef HAVE_PM_CONNECT
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the `seteuid' function. */
#undef HAVE_SETEUID
/* Define to 1 if you have the `setsid' function. */
#undef HAVE_SETSID
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to enable SSL development code */
#undef HAVE_SSL
/* 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
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strptime' function. */
#undef HAVE_STRPTIME
/* Define to 1 if the system has the type `struct addrinfo'. */
#undef HAVE_STRUCT_ADDRINFO
/* Define to 1 if the system has the type `struct in6_addr'. */
#undef HAVE_STRUCT_IN6_ADDR
/* Define to 1 if the system has the type `struct sockaddr_in6'. */
#undef HAVE_STRUCT_SOCKADDR_IN6
/* Define to 1 if the system has the type `struct sockaddr_storage'. */
#undef HAVE_STRUCT_SOCKADDR_STORAGE
/* Define to 1 if you have the <sys/modem.h> header file. */
#undef HAVE_SYS_MODEM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/termios.h> header file. */
#undef HAVE_SYS_TERMIOS_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <tcpd.h> header file. */
#undef HAVE_TCPD_H
/* Define to 1 if you have the `tcsendbreak' function. */
#undef HAVE_TCSENDBREAK
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `usb_detach_kernel_driver_np' function. */
#undef HAVE_USB_DETACH_KERNEL_DRIVER_NP
/* Define to 1 if you have the <usb.h> header file. */
#undef HAVE_USB_H
/* Define to 1 if you have the `usb_init' function. */
#undef HAVE_USB_INIT
/* Use uu_lock for locking (FreeBSD) */
#undef HAVE_UU_LOCK
/* Define to 1 if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Define to enable libwrap support */
#undef HAVE_WRAP
/* Default path for HTML files */
#undef HTMLPATH
/* Desired syslog facility - see syslog(3) */
#undef LOG_FACILITY
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to use explicit getopt declarations */
#undef NEED_GETOPT_DECLS
/* Define if getopt.h is needed */
#undef NEED_GETOPT_H
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Path where the pid files should go */
#undef PIDPATH
/* Port for network communications */
#undef PORT
/* Group membership of user to switch to if started as root */
#undef RUN_AS_GROUP
/* User to switch to if started as root */
#undef RUN_AS_USER
/* The size of `char', as computed by sizeof. */
#undef SIZEOF_CHAR
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `short', as computed by sizeof. */
#undef SIZEOF_SHORT
/* The size of `void*', as computed by sizeof. */
#undef SIZEOF_VOIDP
/* Path for UPS driver state files */
#undef STATEPATH
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* 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>. */
#undef TIME_WITH_SYS_TIME
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Version number of package */
#undef VERSION
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* Replace missing __func__ declaration */
#undef __func__
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* type to use in place of socklen_t if not defined */
#undef socklen_t

26
include/extstate.h Normal file
View file

@ -0,0 +1,26 @@
/* external state structures used by things like upsd */
#ifndef EXTSTATE_H_SEEN
#define EXTSTATE_H_SEEN 1
/* this could be made dynamic if someone really needs more than this... */
#define ST_MAX_VALUE_LEN 256
/* state tree flags */
#define ST_FLAG_RW 0x0001
#define ST_FLAG_STRING 0x0002
#define ST_FLAG_IMMUTABLE 0x0004
/* list of possible ENUM values */
struct enum_t {
char *val;
struct enum_t *next;
};
/* list of instant commands */
struct cmdlist_t {
char *name;
struct cmdlist_t *next;
};
#endif /* EXTSTATE_H_SEEN */

3
include/nut_version.h Normal file
View file

@ -0,0 +1,3 @@
/* Autogenerated file. Do not change. */
/* This file was generated by "make". */
#define NUT_VERSION_MACRO "2.4.3-2365:2366"

75
include/parseconf.h Normal file
View file

@ -0,0 +1,75 @@
/* parseconf.h - state machine-driven dynamic configuration file parser
Copyright (C) 2002 Russell Kroll <rkroll@exploits.org>
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 PARSECONF_H_SEEN
#define PARSECONF_H_SEEN 1
#ifdef __cplusplus
extern "C" {
#endif
#define PCONF_CTX_t_MAGIC 0x00726630
#define PCONF_ERR_LEN 256
/* conservative defaults: use at most 16 KB for parsing any given line */
#define PCONF_DEFAULT_ARG_LIMIT 32
#define PCONF_DEFAULT_WORDLEN_LIMIT 512
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 */
size_t maxargs; /* for reallocing arglist */
char *wordbuf; /* accumulator for current word */
char *wordptr; /* where next char goes in word */
size_t wordbufsize; /* for reallocing wordbuf */
int linenum; /* for good error reporting */
int error; /* set when an error occurred */
char errmsg[PCONF_ERR_LEN]; /* local buffer for errors */
void (*errhandler)(const char *); /* user's error handler */
int magic; /* buffer validity check */
/* these may be redefined by the caller to customize memory use */
size_t arg_limit; /* halts growth of arglist */
size_t wordlen_limit; /* halts growth of any wordbuf */
} PCONF_CTX_t;
int pconf_init(PCONF_CTX_t *ctx, void errhandler(const char *));
int pconf_file_begin(PCONF_CTX_t *ctx, const char *fn);
int pconf_file_next(PCONF_CTX_t *ctx);
int pconf_parse_error(PCONF_CTX_t *ctx);
int pconf_line(PCONF_CTX_t *ctx, const char *line);
void pconf_finish(PCONF_CTX_t *ctx);
char *pconf_encode(const char *src, char *dest, size_t destsize);
int pconf_char(PCONF_CTX_t *ctx, char ch);
#ifdef __cplusplus
}
#endif
#endif /* PARSECONF_H_SEEN */

82
include/proto.h Normal file
View file

@ -0,0 +1,82 @@
#ifndef PROTO_H
#define PROTO_H
#include "attribute.h"
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
/* Define this as a fall through, HAVE_STDARG_H is probably already set */
#ifndef HAVE_VARARGS_H
#define HAVE_VARARGS_H
#endif
/* varargs declarations: */
#if defined(HAVE_STDARG_H)
# include <stdarg.h>
# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
# define VA_LOCAL_DECL va_list ap
# define VA_START(f) va_start(ap, f)
# define VA_SHIFT(v,t) ; /* no-op for ANSI */
# define VA_END va_end(ap)
#else
# if defined(HAVE_VARARGS_H)
# include <varargs.h>
# undef HAVE_STDARGS
# define VA_LOCAL_DECL va_list ap
# define VA_START(f) va_start(ap) /* f is ignored! */
# define VA_SHIFT(v,t) v = va_arg(ap,t)
# define VA_END va_end(ap)
# else
/*XX ** NO VARARGS ** XX*/
# endif
#endif
#if !defined (HAVE_SNPRINTF) || defined (__Lynx__)
int snprintf (char *str, size_t count, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
#endif
#if !defined (HAVE_VSNPRINTF)
int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
#endif
#endif
#ifndef HAVE_SETENV
int nut_setenv(const char *name, const char *value, int overwrite);
static inline int setenv(const char *name, const char *value, int overwrite) {
return nut_setenv(name, value, overwrite);
}
#endif
#ifdef __hpux
#ifdef HAVE_SYS_MODEM_H
#include <sys/modem.h>
#endif
/* See sys/termio.h and sys/modem.h
The following serial bits are not defined by HPUX.
The numbers are octal like I found in BSD.
TIOCM_ST is used in genericups.[ch] for the Powerware 3115.
These defines make it compile, but I have no idea if it works.
*/
#define TIOCM_LE 0001 /* line enable */
#define TIOCM_ST 0010 /* secondary transmit */
#define TIOCM_SR 0020 /* secondary receive */
#endif
#ifdef HAVE_GETPASSPHRASE
#define GETPASS getpassphrase
#else
#define GETPASS getpass
#endif
#ifdef __Lynx__
/* Missing prototypes on LynxOS */
int seteuid(uid_t);
int vprintf(const char *, va_list);
int putenv(char *);
#endif
#endif /* PROTO_H */

57
include/state.h Normal file
View file

@ -0,0 +1,57 @@
/* state.h - Network UPS Tools common state management functions
Copyright (C) 2003 Russell Kroll <rkroll@exploits.org>
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 "extstate.h"
#define ST_SOCK_BUF_LEN 512
struct st_tree_t {
char *var;
char *val; /* points to raw or safe */
char *raw; /* raw data from caller */
size_t rawsize;
char *safe; /* safe data from pconf_encode */
size_t safesize;
int flags;
int aux;
struct enum_t *enum_list;
struct st_tree_t *left;
struct st_tree_t *right;
};
int state_setinfo(struct st_tree_t **nptr, const char *var, const char *val);
int state_addenum(struct st_tree_t *root, const char *var, const char *val);
int state_setaux(struct st_tree_t *root, const char *var, const char *auxs);
const char *state_getinfo(struct st_tree_t *root, const char *var);
int state_getflags(struct st_tree_t *root, const char *var);
int state_getaux(struct st_tree_t *root, const char *var);
const struct enum_t *state_getenumlist(struct st_tree_t *root, const char *var);
void state_setflags(struct st_tree_t *root, const char *var, int numflags, char **flags);
int state_addcmd(struct cmdlist_t **list, const char *cmd);
void state_infofree(struct st_tree_t *node);
void state_cmdfree(struct cmdlist_t *list);
int state_delcmd(struct cmdlist_t **list, const char *cmd);
int state_delinfo(struct st_tree_t **root, const char *var);
int state_delenum(struct st_tree_t *root, const char *var, const char *val);
struct st_tree_t *state_tree_find(struct st_tree_t *node, const char *var);

13
include/timehead.h Normal file
View file

@ -0,0 +1,13 @@
/* from the autoconf docs: sanely include the right time headers everywhere */
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif

7
include/upsconf.h Normal file
View file

@ -0,0 +1,7 @@
/* 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);