From ccd43fc520cbed4cf7fe11f31903d880042c6e49 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 10:01:26 +0200 Subject: [PATCH 01/16] m4/ax_realpath_lib.m4, tools/nut-scanner/nutscan-init.c: add HP-UX *.sl file name patterns into the loop [#2431] Signed-off-by: Jim Klimov --- m4/ax_realpath_lib.m4 | 9 ++++++--- tools/nut-scanner/nutscan-init.c | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/m4/ax_realpath_lib.m4 b/m4/ax_realpath_lib.m4 index 0ee4fe598d..ca97bc9c47 100644 --- a/m4/ax_realpath_lib.m4 +++ b/m4/ax_realpath_lib.m4 @@ -53,12 +53,15 @@ AC_DEFUN([AX_REALPATH_LIB], dnl # Primarily we care to know dynamically linked (shared object) dnl # files, so inject the extension to the presumed base name AS_CASE(["${myLIBNAME}"], - [*.so*|*.a|*.o|*.lo|*.la|*.dll|*.dll.a|*.lib|*.dylib], [], + [*.so*|*.a|*.o|*.lo|*.la|*.dll|*.dll.a|*.lib|*.dylib|*.sl], [], [ AS_CASE(["${target_os}"], [*mingw*], [myLIBNAME="${myLIBNAME}.dll"], [*darwin*], [myLIBNAME="${myLIBNAME}.dylib"], - [myLIBNAME="${myLIBNAME}.so"]) + [*hpux*|*hp?ux*], [ + dnl # See detailed comments in nutscan-init.c + myLIBNAME="${myLIBNAME}.sl" + ],[myLIBNAME="${myLIBNAME}.so"]) ] ) @@ -67,7 +70,7 @@ AC_DEFUN([AX_REALPATH_LIB], dnl Alas, the portable solution with sed is to avoid dnl parentheses and pipe chars, got too many different dnl ways to escape them in the wild - myLIBNAME_LD="`echo "$myLIBNAME" | sed -e 's/^lib/-l/' -e 's/\.dll$//' -e 's/\.dll\.a$//' -e 's/\.a$//' -e 's/\.o$//' -e 's/\.la$//' -e 's/\.lo$//' -e 's/\.lib$//' -e 's/\.dylib$//' -e 's/\.so\..*$//' -e 's/\.so//'`" + myLIBNAME_LD="`echo "$myLIBNAME" | sed -e 's/^lib/-l/' -e 's/\.dll$//' -e 's/\.dll\.a$//' -e 's/\.a$//' -e 's/\.o$//' -e 's/\.la$//' -e 's/\.lo$//' -e 's/\.lib$//' -e 's/\.dylib$//' -e 's/\.so\..*$//' -e 's/\.so//' -e 's/\.sl\..*$//' -e 's/\.sl//'`" ], [myLIBNAME_LD="-l$myLIBNAME"] dnl best-effort... ) diff --git a/tools/nut-scanner/nutscan-init.c b/tools/nut-scanner/nutscan-init.c index a0246f52fc..31fd0861cf 100644 --- a/tools/nut-scanner/nutscan-init.c +++ b/tools/nut-scanner/nutscan-init.c @@ -50,8 +50,21 @@ #else # ifdef NUT_PLATFORM_APPLE_OSX # define SOEXT ".dylib" -# else /* not WIN32, not MACOS */ -# define SOEXT ".so" +# else +# ifdef NUT_PLATFORM_HPUX + /* Note: depending on CPU arch and OS version, library file name + * patterns here could have been "*.so" as well. E.g. per + * https://community.hpe.com/t5/operating-system-hp-ux/so-and-sl-files/td-p/3780528 + * *.sl are used in PA-RISC (11.11) + * *.so shared libraries are used in HP-UX 11.20 and upwards. + * Integrity (Itanium-based) HPUX can use *.sl as well, but it + * is not recommended, see ld(1) under -lx: + * https://web.archive.org/web/20090925153446/http://docs.hp.com/en/B2355-60103/ld.1.html + */ +# define SOEXT ".sl" +# else /* not WIN32, not MACOS, not HPUX */ +# define SOEXT ".so" +# endif # endif #endif From 2ba14449e1d7d2bf94ccc57f1a92dd021ed267cc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 12:11:10 +0200 Subject: [PATCH 02/16] docs/config-prereqs.txt: for platforms that offer a choice of python2/3 package names, separate its installation sample from the big block of unambiguous packages [#2467] Signed-off-by: Jim Klimov --- docs/config-prereqs.txt | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/config-prereqs.txt b/docs/config-prereqs.txt index e789d4f056..bb3a4b6802 100644 --- a/docs/config-prereqs.txt +++ b/docs/config-prereqs.txt @@ -141,7 +141,7 @@ metadata about recently published package revisions: :; apt-get install \ ccache time \ - git python perl curl \ + git perl curl \ make autoconf automake libltdl-dev libtool \ valgrind \ cppcheck \ @@ -152,6 +152,10 @@ metadata about recently published package revisions: :; apt-get install \ libtool-bin +# See comments below, python version and package naming depends on distro +:; apt-get install \ + python + # NOTE: For python, you may eventually have to specify a variant like this # (numbers depending on default or additional packages of your distro): # :; apt-get install python2 python2.7 python-is-python2 @@ -338,13 +342,17 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome. :; yum install \ ccache time \ file \ - git python perl curl \ + git perl curl \ make autoconf automake libtool-ltdl-devel libtool \ valgrind \ cppcheck \ pkgconfig \ gcc gcc-c++ clang +# See comments below, python version and package naming depends on distro +:; yum install \ + python + # NOTE: For python, you may eventually have to specify a variant like this # (numbers depending on default or additional packages of your distro): # :; yum install python-2.7.5 @@ -688,13 +696,17 @@ below. ------ :; pkg install \ - git python perl5 curl \ + git perl5 curl \ gmake autoconf automake autotools libltdl libtool \ valgrind \ cppcheck \ pkgconf \ gcc clang +# See comments below, python version and package naming depends on distro +:; pkg install \ + python + # NOTE: For python, you may eventually have to specify a variant like this # (numbers depending on default or additional packages of your distro): # :; pkg install python2 python27 @@ -816,13 +828,17 @@ default site. :; pkg_add sudo bash mc wget rsync :; pkg_add \ - git python curl \ + git curl \ gmake autoconf automake libltdl libtool \ valgrind \ cppcheck \ pkgconf \ gcc clang +# See comments below, python version and package naming depends on distro +:; pkg_add \ + python + # NOTE: For python, you may eventually have to specify a variant like this # (numbers depending on default or additional packages of your distro): # :; pkg_add python-2.7.15p0 py-pip @@ -956,12 +972,16 @@ you can work around by `make MKDIRPROG="mkdir -p" install -j 8` for example. ------ :; pkgin install \ - git python27 python39 perl curl \ + git perl curl \ make gmake autoconf automake libltdl libtool \ cppcheck \ pkgconf \ gcc7 clang +# See comments below, python version and package naming depends on distro +:; apt-get install \ + python27 python39 + ;; ( cd /usr/pkg/bin && ( ln -fs python2.7 python2 ; ln -fs python3.9 python3 ) ) # You can find a list of what is (pre-)installed with: # :; pkgin list | grep -Ei 'perl|python' From 647d5d34439cdb4ae303d031f6d648a3cb3aaf5e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 10:19:38 +0200 Subject: [PATCH 03/16] *.{c,h}: Revise indentation of nested preprocessor clauses/code - vol.2 Conform to NUT code style guide, and satisfy pre-processors that insist on "traditional" code layout by default (hash sign must start the line for them). Signed-off-by: Jim Klimov --- clients/upsclient.c | 20 +++---- clients/upsclient.h | 14 ++--- clients/upsmon.c | 2 +- common/nutwriter.cpp | 8 +-- drivers/apc-mib.c | 6 +- drivers/hwmon_ina219.c | 4 +- drivers/libhid.c | 4 +- drivers/libhid.h | 8 +-- drivers/masterguard.c | 4 +- drivers/mge-utalk.h | 4 +- drivers/microdowell.c | 2 +- drivers/nutdrv_qx.c | 42 +++++++------- drivers/usbhid-ups.c | 30 +++++----- include/nut_platform.h | 98 ++++++++++++++++----------------- include/parseconf.h | 6 +- server/netssl.c | 20 +++---- server/nut_ctype.h | 8 +-- tools/nut-scanner/nut-scanner.c | 4 +- 18 files changed, 142 insertions(+), 142 deletions(-) diff --git a/clients/upsclient.c b/clients/upsclient.c index 9c4f0424fd..37ee6955d0 100644 --- a/clients/upsclient.c +++ b/clients/upsclient.c @@ -62,25 +62,25 @@ /* WA for Solaris/i386 bug: non-blocking connect sets errno to ENOENT */ #if (defined NUT_PLATFORM_SOLARIS) - #define SOLARIS_i386_NBCONNECT_ENOENT(status) ( (!strcmp("i386", CPU_TYPE)) ? (ENOENT == (status)) : 0 ) +# define SOLARIS_i386_NBCONNECT_ENOENT(status) ( (!strcmp("i386", CPU_TYPE)) ? (ENOENT == (status)) : 0 ) #else - #define SOLARIS_i386_NBCONNECT_ENOENT(status) (0) +# define SOLARIS_i386_NBCONNECT_ENOENT(status) (0) #endif /* end of Solaris/i386 WA for non-blocking connect */ /* WA for AIX bug: non-blocking connect sets errno to 0 */ #if (defined NUT_PLATFORM_AIX) - #define AIX_NBCONNECT_0(status) (0 == (status)) +# define AIX_NBCONNECT_0(status) (0 == (status)) #else - #define AIX_NBCONNECT_0(status) (0) +# define AIX_NBCONNECT_0(status) (0) #endif /* end of AIX WA for non-blocking connect */ #ifdef WITH_NSS - #include - #include - #include - #include - #include - #include +# include +# include +# include +# include +# include +# include #endif /* WITH_NSS */ #define UPSCLIENT_MAGIC 0x19980308 diff --git a/clients/upsclient.h b/clients/upsclient.h index 879d55bd83..c359905882 100644 --- a/clients/upsclient.h +++ b/clients/upsclient.h @@ -21,24 +21,24 @@ #define UPSCLIENT_H_SEEN 1 #ifdef WITH_OPENSSL - #include - #include +# include +# include #elif defined(WITH_NSS) /* WITH_OPENSSL */ - #include - #include +# include +# include #endif /* WITH_OPENSSL | WITH_NSS */ /* Not including nut_stdint.h because this is part of end-user API */ #if defined HAVE_INTTYPES_H - #include +# include #endif #if defined HAVE_STDINT_H - #include +# include #endif #if defined HAVE_LIMITS_H - #include +# include #endif /* Not including NUT timehead.h because this is part of end-user API */ diff --git a/clients/upsmon.c b/clients/upsmon.c index 53be6395d1..2ac1a0d716 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -206,7 +206,7 @@ static void wall(const char *text) fprintf(wf, "%s\n", text); pclose(wf); #else - #define MESSAGE_CMD "message.exe" +# define MESSAGE_CMD "message.exe" char * command; /* first +1 is for the space between message and text diff --git a/common/nutwriter.cpp b/common/nutwriter.cpp index f483b58467..a299462783 100644 --- a/common/nutwriter.cpp +++ b/common/nutwriter.cpp @@ -555,7 +555,7 @@ NutWriter::status_t UpsmonConfigWriter::writeConfig(const UpsmonConfiguration & * \param arg Directive argument * \param quote_arg Boolean flag; check to quote the argument */ - #define UPSMON_DIRECTIVEX(name, arg_t, arg, quote_arg) \ +# define UPSMON_DIRECTIVEX(name, arg_t, arg, quote_arg) \ CONFIG_DIRECTIVEX(name, arg_t, arg, quote_arg) /* The "false" arg in macro below evaluates to `if (false) ...` after @@ -631,7 +631,7 @@ NutWriter::status_t UpsmonConfigWriter::writeConfig(const UpsmonConfiguration & # pragma GCC diagnostic pop #endif - #undef UPSMON_DIRECTIVEX +# undef UPSMON_DIRECTIVEX // Certificate identity if (config.certIdent.set()) { @@ -735,7 +735,7 @@ NutWriter::status_t UpsdConfigWriter::writeConfig(const UpsdConfiguration & conf * \param arg_t Directive argument implementation type * \param arg Directive argument */ - #define UPSD_DIRECTIVEX(name, arg_t, arg) \ +# define UPSD_DIRECTIVEX(name, arg_t, arg) \ CONFIG_DIRECTIVEX(name, arg_t, arg, false) /* The "false" arg in macro below evaluates to `if (false) ...` after @@ -769,7 +769,7 @@ NutWriter::status_t UpsdConfigWriter::writeConfig(const UpsdConfiguration & conf # pragma GCC diagnostic pop #endif - #undef UPSD_DIRECTIVEX +# undef UPSD_DIRECTIVEX // Certificate identity if (config.certIdent.set()) { diff --git a/drivers/apc-mib.c b/drivers/apc-mib.c index 1c6c575ac6..78924e31c3 100644 --- a/drivers/apc-mib.c +++ b/drivers/apc-mib.c @@ -164,9 +164,9 @@ static info_lkp_t apcc_transfer_reasons[] = { #define APCC_REBOOT_DO 2 #define APCC_REBOOT_GRACEFUL 3 #if 0 /* not used. */ - #define APCC_OID_SLEEP ".1.3.6.1.4.1.318.1.1.1.6.2.3" - #define APCC_SLEEP_ON "2" - #define APCC_SLEEP_GRACEFUL "3" +# define APCC_OID_SLEEP ".1.3.6.1.4.1.318.1.1.1.6.2.3" +# define APCC_SLEEP_ON "2" +# define APCC_SLEEP_GRACEFUL "3" #endif diff --git a/drivers/hwmon_ina219.c b/drivers/hwmon_ina219.c index c0cacd02e3..988208a2a1 100644 --- a/drivers/hwmon_ina219.c +++ b/drivers/hwmon_ina219.c @@ -27,10 +27,10 @@ #include #ifndef STRFY0 - #define STRFY0(x) #x +# define STRFY0(x) #x #endif #ifndef STRFY - #define STRFY(x) STRFY0(x) +# define STRFY(x) STRFY0(x) #endif #define SYSFS_HWMON_DIR "/sys/class/hwmon" diff --git a/drivers/libhid.c b/drivers/libhid.c index b23c811446..8aa6c179f2 100644 --- a/drivers/libhid.c +++ b/drivers/libhid.c @@ -47,10 +47,10 @@ /* Communication layers and drivers (USB and MGE SHUT) */ #if (defined SHUT_MODE) && SHUT_MODE - #include "libshut.h" +# include "libshut.h" communication_subdriver_t *comm_driver = &shut_subdriver; #else /* !SHUT_MODE => USB */ - #include "nut_libusb.h" +# include "nut_libusb.h" communication_subdriver_t *comm_driver = &usb_subdriver; #endif /* SHUT_MODE / USB */ diff --git a/drivers/libhid.h b/drivers/libhid.h index 1711b1b539..bb068296d8 100644 --- a/drivers/libhid.h +++ b/drivers/libhid.h @@ -44,19 +44,19 @@ #include "timehead.h" #if (defined SHUT_MODE) && SHUT_MODE - #include "libshut.h" +# include "libshut.h" typedef SHUTDevice_t HIDDevice_t; typedef char HIDDeviceMatcher_t; typedef usb_dev_handle hid_dev_handle_t; typedef shut_communication_subdriver_t communication_subdriver_t; - #define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(ERROR_FD_SER) +# define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(ERROR_FD_SER) #else /* !SHUT_MODE => USB */ - #include "nut_libusb.h" /* includes usb-common.h */ +# include "nut_libusb.h" /* includes usb-common.h */ typedef USBDevice_t HIDDevice_t; typedef USBDeviceMatcher_t HIDDeviceMatcher_t; typedef usb_dev_handle * hid_dev_handle_t; typedef usb_communication_subdriver_t communication_subdriver_t; - #define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(NULL) +# define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(NULL) #endif /* SHUT_MODE / USB */ /* use explicit booleans */ diff --git a/drivers/masterguard.c b/drivers/masterguard.c index 72c48c537a..f5bbb397ce 100644 --- a/drivers/masterguard.c +++ b/drivers/masterguard.c @@ -164,7 +164,7 @@ static void parseFlags( char *flags ) ********************************************************************/ static void query1( char *buf ) { - #define WORDMAXLEN 255 +# define WORDMAXLEN 255 char value[WORDMAXLEN]; char word[WORDMAXLEN]; char *newPOS; @@ -238,7 +238,7 @@ static void query1( char *buf ) ********************************************************************/ static void query3( char *buf ) { - #define WORDMAXLEN 255 +# define WORDMAXLEN 255 char value[WORDMAXLEN]; char word[WORDMAXLEN]; char *newPOS; diff --git a/drivers/mge-utalk.h b/drivers/mge-utalk.h index 67b1135533..91efb054f1 100644 --- a/drivers/mge-utalk.h +++ b/drivers/mge-utalk.h @@ -173,10 +173,10 @@ static const double multiplier[4][8] = { /* use explicit booleans */ #ifdef FALSE - #undef FALSE +# undef FALSE #endif /* FALSE */ #ifdef TRUE - #undef TRUE +# undef TRUE #endif /* TRUE */ typedef enum ebool { FALSE=0, TRUE } bool_t; diff --git a/drivers/microdowell.c b/drivers/microdowell.c index 490fd4140b..0d491b1c7e 100644 --- a/drivers/microdowell.c +++ b/drivers/microdowell.c @@ -213,7 +213,7 @@ static void SendCmdToSerial(unsigned char *Buff, size_t Len) static unsigned char * CmdSerial(unsigned char *OutBuffer, size_t Len, unsigned char *RetBuffer) { - #define TMP_BUFF_LEN 1024 +# define TMP_BUFF_LEN 1024 unsigned char InpBuff[TMP_BUFF_LEN+1] ; unsigned char TmpBuff[3] ; int i, ErrCode ; diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index a50728a356..b90b50d0dd 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -47,22 +47,22 @@ /* note: QX_USB/QX_SERIAL set through Makefile */ #ifdef QX_USB - #include "nut_libusb.h" /* also includes "usb-common.h" */ +# include "nut_libusb.h" /* also includes "usb-common.h" */ - #ifdef QX_SERIAL - #define DRIVER_NAME "Generic Q* USB/Serial driver" - #else - #define DRIVER_NAME "Generic Q* USB driver" - #endif /* QX_SERIAL */ +# ifdef QX_SERIAL +# define DRIVER_NAME "Generic Q* USB/Serial driver" +# else +# define DRIVER_NAME "Generic Q* USB driver" +# endif /* QX_SERIAL */ #else - #define DRIVER_NAME "Generic Q* Serial driver" +# define DRIVER_NAME "Generic Q* Serial driver" #endif /* QX_USB */ #define DRIVER_VERSION "0.36" #ifdef QX_SERIAL - #include "serial.h" - #define SER_WAIT_SEC 1 /* 3 seconds for Best UPS */ +# include "serial.h" +# define SER_WAIT_SEC 1 /* 3 seconds for Best UPS */ #endif /* QX_SERIAL */ #include "nutdrv_qx.h" @@ -2871,7 +2871,7 @@ void upsdrv_shutdown(void) } #ifdef QX_USB - #ifndef TESTING +# ifndef TESTING static const struct { const char *name; int (*command)(const char *cmd, char *buf, size_t buflen); @@ -2890,7 +2890,7 @@ void upsdrv_shutdown(void) { "armac", &armac_command }, { NULL, NULL } }; - #endif +# endif #endif @@ -3193,13 +3193,13 @@ void upsdrv_initups(void) /* Serial */ #ifdef QX_SERIAL - #ifdef QX_USB +# ifdef QX_USB if (!is_usb) { - #else +# else { /* scoping */ - #endif /* QX_USB */ +# endif /* QX_USB */ - #ifndef TESTING +# ifndef TESTING const struct { const char *val; @@ -3260,13 +3260,13 @@ void upsdrv_initups(void) /* Allow some time to settle for the cablepower */ usleep(100000); - #endif /* TESTING */ +# endif /* TESTING */ - #ifdef QX_USB +# ifdef QX_USB } else { /* is_usb */ - #else +# else } /* end of scoping */ - #endif /* QX_USB */ +# endif /* QX_USB */ #endif /* QX_SERIAL */ @@ -3529,7 +3529,7 @@ static ssize_t qx_command(const char *cmd, char *buf, size_t buflen) # endif #endif - #if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ +# if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -EPERM: /* Operation not permitted */ fatal_with_errno(EXIT_FAILURE, "Permissions problem"); #ifndef HAVE___ATTRIBUTE__NORETURN @@ -3542,7 +3542,7 @@ static ssize_t qx_command(const char *cmd, char *buf, size_t buflen) # pragma GCC diagnostic pop # endif #endif - #endif /* WITH_LIBUSB_0_1 */ +# endif /* WITH_LIBUSB_0_1 */ case LIBUSB_ERROR_PIPE: /* Broken pipe */ if (usb_clear_halt(udev, 0x81) == 0) { diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index 6856036bb3..d833091340 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -49,21 +49,21 @@ #if !((defined SHUT_MODE) && SHUT_MODE) /* explore stub goes first, others alphabetically */ - #include "explore-hid.h" - #include "apc-hid.h" - #include "arduino-hid.h" - #include "belkin-hid.h" - #include "cps-hid.h" - #include "delta_ups-hid.h" - #include "ever-hid.h" - #include "idowell-hid.h" - #include "legrand-hid.h" - #include "liebert-hid.h" - #include "openups-hid.h" - #include "powercom-hid.h" - #include "powervar-hid.h" - #include "salicru-hid.h" - #include "tripplite-hid.h" +# include "explore-hid.h" +# include "apc-hid.h" +# include "arduino-hid.h" +# include "belkin-hid.h" +# include "cps-hid.h" +# include "delta_ups-hid.h" +# include "ever-hid.h" +# include "idowell-hid.h" +# include "legrand-hid.h" +# include "liebert-hid.h" +# include "openups-hid.h" +# include "powercom-hid.h" +# include "powervar-hid.h" +# include "salicru-hid.h" +# include "tripplite-hid.h" #endif /* !SHUT_MODE => USB */ /* Reference list of available subdrivers */ diff --git a/include/nut_platform.h b/include/nut_platform.h index ba640c5a7c..8664541ae9 100644 --- a/include/nut_platform.h +++ b/include/nut_platform.h @@ -27,26 +27,26 @@ /* Apple Mac OS X, iOS and Darwin */ #if (defined __APPLE__ && defined __MACH__) /** Apple OS based on Mach ukernel */ - #define NUT_PLATFORM_APPLE_MACH +# define NUT_PLATFORM_APPLE_MACH - #include +# include - #if (defined TARGET_OS_EMBEDDED) +# if (defined TARGET_OS_EMBEDDED) /** iOS (implies \ref NUT_PLATFORM_APPLE_MACH) */ - #define NUT_PLATFORM_APPLE_IOS - #endif - #if (defined TARGET_IPHONE_SIMULATOR) +# define NUT_PLATFORM_APPLE_IOS +# endif +# if (defined TARGET_IPHONE_SIMULATOR) /** iOS simulator (implies \ref NUT_PLATFORM_APPLE_MACH) */ - #define NUT_PLATFORM_APPLE_IOS_SIMULATOR - #endif - #if (defined TARGET_OS_IPHONE) +# define NUT_PLATFORM_APPLE_IOS_SIMULATOR +# endif +# if (defined TARGET_OS_IPHONE) /** iPhone (implies \ref NUT_PLATFORM_APPLE_MACH) */ - #define NUT_PLATFORM_APPLE_IPHONE - #endif - #if (defined TARGET_OS_MAC) +# define NUT_PLATFORM_APPLE_IPHONE +# endif +# if (defined TARGET_OS_MAC) /** Mac OS X (implies \ref NUT_PLATFORM_APPLE_MACH) */ - #define NUT_PLATFORM_APPLE_OSX - #endif +# define NUT_PLATFORM_APPLE_OSX +# endif #endif /* @@ -56,69 +56,69 @@ * Remove if no longer necessary */ #if (defined _AIX && !defined __unix__) - #define __unix__ +# define __unix__ #endif /* Microsoft Windows */ #if (defined _WIN32 || defined _WIN64) /** Windows */ - #define NUT_PLATFORM_MS_WINDOWS +# define NUT_PLATFORM_MS_WINDOWS - #if (defined NTDDI_WIN8 && NTDDI_VERSION >= NTDDI_WIN8) +# if (defined NTDDI_WIN8 && NTDDI_VERSION >= NTDDI_WIN8) /** Windows 8 */ - #define NUT_PLATFORM_MS_WINDOWS8 - #endif +# define NUT_PLATFORM_MS_WINDOWS8 +# endif /* UNIX */ /* Note that Apple OSX doesn't define __unix__ nor __unix; are they ashamed or something? */ #elif (defined __unix__ || defined __unix || defined NUT_PLATFORM_APPLE_MACH) - #include - #include +# include +# include /** UNIX */ - #define NUT_PLATFORM_UNIX +# define NUT_PLATFORM_UNIX - #if (defined _POSIX_VERSION) +# if (defined _POSIX_VERSION) /** POSIX (implies \ref NUT_PLATFORM_UNIX), expands to POSIX version */ - #define NUT_PLATFORM_POSIX _POSIX_VERSION - #endif +# define NUT_PLATFORM_POSIX _POSIX_VERSION +# endif - #if (defined __linux__) +# if (defined __linux__) /** Linux (implies \ref NUT_PLATFORM_UNIX) */ - #define NUT_PLATFORM_LINUX - #endif - #if (defined __sun && defined __SVR4) +# define NUT_PLATFORM_LINUX +# endif +# if (defined __sun && defined __SVR4) /** Solaris (implies \ref NUT_PLATFORM_UNIX) */ - #define NUT_PLATFORM_SOLARIS - #endif - #if (defined __hpux) +# define NUT_PLATFORM_SOLARIS +# endif +# if (defined __hpux) /** Hewlett-Packard HP-UX (implies \ref NUT_PLATFORM_UNIX) */ - #define NUT_PLATFORM_HPUX - #endif - #if (defined _AIX) +# define NUT_PLATFORM_HPUX +# endif +# if (defined _AIX) /** AIX (implies \ref NUT_PLATFORM_UNIX) */ - #define NUT_PLATFORM_AIX - #endif +# define NUT_PLATFORM_AIX +# endif /* Note that BSD is defined in sys/param.h */ - #if (defined BSD) +# if (defined BSD) /** BSD (implies \ref NUT_PLATFORM_UNIX) */ - #define NUT_PLATFORM_BSD +# define NUT_PLATFORM_BSD - #if (defined __DragonFly__) +# if (defined __DragonFly__) /** DragonFly (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */ - #define NUT_PLATFORM_DRAGONFLY - #elif (defined __FreeBSD__) +# define NUT_PLATFORM_DRAGONFLY +# elif (defined __FreeBSD__) /** FreeBSD (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */ - #define NUT_PLATFORM_FREEBSD - #elif (defined __OpenBSD__) +# define NUT_PLATFORM_FREEBSD +# elif (defined __OpenBSD__) /** OpenBSD (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */ - #define NUT_PLATFORM_OPENBSD - #elif (defined __NetBSD__) +# define NUT_PLATFORM_OPENBSD +# elif (defined __NetBSD__) /** NetBSD (implies \ref NUT_PLATFORM_UNIX, \ref NUT_PLATFORM_BSD) */ - #define NUT_PLATFORM_NETBSD - #endif - #endif +# define NUT_PLATFORM_NETBSD +# endif +# endif #endif #endif /* NUT_PLATFORM_H_SEEN */ diff --git a/include/parseconf.h b/include/parseconf.h index 828a1e09b3..3c8c8851da 100644 --- a/include/parseconf.h +++ b/include/parseconf.h @@ -24,15 +24,15 @@ /* Not including nut_stdint.h because this is part of end-user API */ #if defined HAVE_INTTYPES_H - #include +# include #endif #if defined HAVE_STDINT_H - #include +# include #endif #if defined HAVE_LIMITS_H - #include +# include #endif #ifdef __cplusplus diff --git a/server/netssl.c b/server/netssl.c index d92fb1ba89..cd8f490dcb 100644 --- a/server/netssl.c +++ b/server/netssl.c @@ -40,19 +40,19 @@ #include "nut_stdint.h" #ifdef WITH_NSS - #include - #include - #include +# include +# include +# include #if defined(NSS_VMAJOR) && (NSS_VMAJOR > 3 || (NSS_VMAJOR == 3 && defined(NSS_VMINOR) && NSS_VMINOR >= 39)) - #include - #include +# include +# include #else - #include - #include +# include +# include #endif /* NSS before 3.39 */ - #include - #include - #include +# include +# include +# include #endif /* WITH_NSS */ char *certfile = NULL; diff --git a/server/nut_ctype.h b/server/nut_ctype.h index 25cead0754..55ce735220 100644 --- a/server/nut_ctype.h +++ b/server/nut_ctype.h @@ -27,14 +27,14 @@ /* Mozilla NSS */ #ifdef WITH_NSS - #include - #include +# include +# include #endif /* OpenSSL */ #ifdef WITH_OPENSSL - #include - #include +# include +# include #endif #include "parseconf.h" diff --git a/tools/nut-scanner/nut-scanner.c b/tools/nut-scanner/nut-scanner.c index ebfacc9aa7..339881ac5d 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -310,8 +310,8 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr) * https://stackoverflow.com/questions/41139561/find-ip-address-of-the-machine-in-c/41151132#41151132 */ - #define WIN32_GAA_WORKING_BUFFER_SIZE 15000 - #define WIN32_GAA_MAX_TRIES 3 +# define WIN32_GAA_WORKING_BUFFER_SIZE 15000 +# define WIN32_GAA_MAX_TRIES 3 DWORD dwRetVal = 0; From d927fa08d744ba498b8ee3c1076ea72bf02899e2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 10:21:53 +0200 Subject: [PATCH 04/16] drivers/libhid.{c,h}: clarify "*NUT* HID Library - User API" in file headings Signed-off-by: Jim Klimov --- drivers/libhid.c | 2 +- drivers/libhid.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/libhid.c b/drivers/libhid.c index 8aa6c179f2..69511b364d 100644 --- a/drivers/libhid.c +++ b/drivers/libhid.c @@ -1,6 +1,6 @@ /*! * @file libhid.c - * @brief HID Library - User API (Generic HID Access using MGE HIDParser) + * @brief NUT HID Library - User API (Generic HID Access using MGE HIDParser) * * @author Copyright (C) 2003 - 2007 * Arnaud Quette && diff --git a/drivers/libhid.h b/drivers/libhid.h index bb068296d8..4a916a6fb4 100644 --- a/drivers/libhid.h +++ b/drivers/libhid.h @@ -1,6 +1,6 @@ /*! * @file libhid.h - * @brief HID Library - User API + * @brief NUT HID Library - User API * * @author Copyright (C) 2003 - 2007 * Arnaud Quette && From dc49c9596c2a725edaf1743c5a2c5b5e8fa665bb Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 10:42:02 +0200 Subject: [PATCH 05/16] tools/nut-scanner/nutscan-init.c, include/nut_platform.h, m4/ax_realpath_lib.m4: move definition of SOEXT to the header [#2431] This would allow the multiplatform-aware library-picking logic to be used elsewhere (e.g. DMF) eventually. Signed-off-by: Jim Klimov --- include/nut_platform.h | 30 ++++++++++++++++++++++++++++++ m4/ax_realpath_lib.m4 | 2 +- tools/nut-scanner/nutscan-init.c | 25 ------------------------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/include/nut_platform.h b/include/nut_platform.h index 8664541ae9..90237d2600 100644 --- a/include/nut_platform.h +++ b/include/nut_platform.h @@ -29,6 +29,11 @@ /** Apple OS based on Mach ukernel */ # define NUT_PLATFORM_APPLE_MACH + /* https://stackoverflow.com/a/2339910/4715872 */ +# ifndef SOEXT +# define SOEXT ".dylib" +# endif + # include # if (defined TARGET_OS_EMBEDDED) @@ -64,6 +69,10 @@ /** Windows */ # define NUT_PLATFORM_MS_WINDOWS +# ifndef SOEXT +# define SOEXT ".dll" +# endif + # if (defined NTDDI_WIN8 && NTDDI_VERSION >= NTDDI_WIN8) /** Windows 8 */ # define NUT_PLATFORM_MS_WINDOWS8 @@ -94,6 +103,22 @@ # if (defined __hpux) /** Hewlett-Packard HP-UX (implies \ref NUT_PLATFORM_UNIX) */ # define NUT_PLATFORM_HPUX + + /* Note: depending on CPU arch and OS version, library file + * name patterns here could have been "*.so" as well. + * E.g. per + * https://community.hpe.com/t5/operating-system-hp-ux/so-and-sl-files/td-p/3780528 + * *.sl are used in PA-RISC (11.11) + * *.so shared libraries are used in HP-UX 11.20 and upwards. + * Integrity (Itanium-based) HPUX can use *.sl as well, + * but it is not recommended, see ld(1) under -lx: + * https://web.archive.org/web/20090925153446/http://docs.hp.com/en/B2355-60103/ld.1.html + */ + /* FIXME: May want to detect better the CPU or OS version + * to decide the SOEXT here*/ +# ifndef SOEXT +# define SOEXT ".sl" +# endif # endif # if (defined _AIX) /** AIX (implies \ref NUT_PLATFORM_UNIX) */ @@ -121,5 +146,10 @@ # endif #endif +/* not WIN32, not MACOS, not HPUX... */ +#ifndef SOEXT +# define SOEXT ".so" +#endif + #endif /* NUT_PLATFORM_H_SEEN */ diff --git a/m4/ax_realpath_lib.m4 b/m4/ax_realpath_lib.m4 index ca97bc9c47..274517bfd1 100644 --- a/m4/ax_realpath_lib.m4 +++ b/m4/ax_realpath_lib.m4 @@ -59,7 +59,7 @@ AC_DEFUN([AX_REALPATH_LIB], [*mingw*], [myLIBNAME="${myLIBNAME}.dll"], [*darwin*], [myLIBNAME="${myLIBNAME}.dylib"], [*hpux*|*hp?ux*], [ - dnl # See detailed comments in nutscan-init.c + dnl # See detailed comments in nut_platform.h myLIBNAME="${myLIBNAME}.sl" ],[myLIBNAME="${myLIBNAME}.so"]) ] diff --git a/tools/nut-scanner/nutscan-init.c b/tools/nut-scanner/nutscan-init.c index 31fd0861cf..aad15c69d6 100644 --- a/tools/nut-scanner/nutscan-init.c +++ b/tools/nut-scanner/nutscan-init.c @@ -43,31 +43,6 @@ # endif #endif -/* FIXME: We may want to (also?) use lt_dlopenext(), so - * that libtool would offer platform-specific extensions */ -#ifdef WIN32 -# define SOEXT ".dll" -#else -# ifdef NUT_PLATFORM_APPLE_OSX -# define SOEXT ".dylib" -# else -# ifdef NUT_PLATFORM_HPUX - /* Note: depending on CPU arch and OS version, library file name - * patterns here could have been "*.so" as well. E.g. per - * https://community.hpe.com/t5/operating-system-hp-ux/so-and-sl-files/td-p/3780528 - * *.sl are used in PA-RISC (11.11) - * *.so shared libraries are used in HP-UX 11.20 and upwards. - * Integrity (Itanium-based) HPUX can use *.sl as well, but it - * is not recommended, see ld(1) under -lx: - * https://web.archive.org/web/20090925153446/http://docs.hp.com/en/B2355-60103/ld.1.html - */ -# define SOEXT ".sl" -# else /* not WIN32, not MACOS, not HPUX */ -# define SOEXT ".so" -# endif -# endif -#endif - /* Flags for code paths we can support in this run (libs available or not * needed). For consistency, only set non-zero values via nutscan_init() call. */ From c57fc1857a2b2c2003840885a412549f749e5406 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 10:46:57 +0200 Subject: [PATCH 06/16] tools/nut-scanner/nut-scan.h: minor typo fix in comment Signed-off-by: Jim Klimov --- tools/nut-scanner/nut-scan.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nut-scanner/nut-scan.h b/tools/nut-scanner/nut-scan.h index 22d951bd8b..4b09db2578 100644 --- a/tools/nut-scanner/nut-scan.h +++ b/tools/nut-scanner/nut-scan.h @@ -186,7 +186,7 @@ nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_list); #ifdef HAVE_PTHREAD # ifdef HAVE_SEMAPHORE -/* Expose shared libnutscanner semaphore for overall thread count +/* Expose shared libnutscan semaphore for overall thread count * limited across different scanning methods (protocols/media): */ sem_t * nutscan_semaphore(void); # endif From 54b8d09a4d5aba964a46bef6932077e7fd6ea00c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 11:55:15 +0200 Subject: [PATCH 07/16] tools/nut-scanner/nut-scanner.c: count auto-selected subnets, loudly warn if none were chosen [#2244] Signed-off-by: Jim Klimov --- tools/nut-scanner/nut-scanner.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/nut-scanner/nut-scanner.c b/tools/nut-scanner/nut-scanner.c index 339881ac5d..66358fc6bb 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -292,6 +292,7 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr) long masklen_hosts_limit = 8; char *s = NULL; int errno_saved; + size_t auto_subnets_found = 0; #ifdef HAVE_GETIFADDRS /* NOTE: this ifdef is more precise than ifdef WIN32; assuming @@ -925,6 +926,8 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr) nutscan_add_ip_range(&ip_ranges_list, start_ip, end_ip); start_ip = NULL; end_ip = NULL; + + auto_subnets_found++; } /* else AF_UNIX or a dozen other types we do not care about here */ } } @@ -945,7 +948,12 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr) } #endif - upsdebugx(3, "Finished %s('%s')", __func__, arg_addr); + if (!auto_subnets_found) { + upsdebugx(0, "WARNING: A '-m auto*' request selected no subnets!\n" + "Please check for reasons with higher debug verbosity (up to 6)."); + } + upsdebugx(3, "Finished %s('%s'), selected %" PRIuSIZE " subnets automatically", + __func__, arg_addr, auto_subnets_found); } static void show_usage(void) From 2897f19a4f43202a82a50c0dc18ab34dff3b5c54 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 10:49:18 +0200 Subject: [PATCH 08/16] tools/nut-scanner/Makefile.am, NEWS.adoc: bump "minor" semver component [#2511, #2431, #2450 et al] Earlier bump went to "patch" component, but here we actually have an API expansion (and more exported symbols), so the more important component should be bumped. Signed-off-by: Jim Klimov --- NEWS.adoc | 2 +- tools/nut-scanner/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index a59e59c0e8..25aa295e61 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -157,7 +157,7 @@ installed. [issue #2244, issue #2511, PR #2509, PR #2513, PR #2517] * implemented parallel scanning for IPMI bus, otherwise default scan for all supported buses with `-m auto` takes unbearably long. [#2523] - * bumped version of `libnutscan` to 2.5.2, it now includes a few more + * bumped version of `libnutscan` to 2.6.0, it now includes a few more methods and symbols from `libcommon`. [issue #2244, PR #2509] - common code: diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am index 301c593656..a5bdd84372 100644 --- a/tools/nut-scanner/Makefile.am +++ b/tools/nut-scanner/Makefile.am @@ -85,7 +85,7 @@ libnutscan_la_LDFLAGS += @NETLIBS_GETADDRS@ # object .so names would differ) # # libnutscan version information -libnutscan_la_LDFLAGS += -version-info 2:5:2 +libnutscan_la_LDFLAGS += -version-info 2:6:0 # libnutscan exported symbols regex # WARNING: Since the library includes parts of libcommon (as much as needed From 759c2c79d14c4628ba557aec97f6edd6c0e6de19 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 11:27:26 +0200 Subject: [PATCH 09/16] clients/Makefile.am, clients/.gitignore: generate a client/libupsclient-version.h from libtool information file [#2431] Signed-off-by: Jim Klimov --- clients/.gitignore | 1 + clients/Makefile.am | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/clients/.gitignore b/clients/.gitignore index 26183d14df..c422f84a7d 100644 --- a/clients/.gitignore +++ b/clients/.gitignore @@ -1,3 +1,4 @@ +/libupsclient-version.h /upsimage.cgi /upsset.cgi /upsstats.cgi diff --git a/clients/Makefile.am b/clients/Makefile.am index 6c7e9b914e..2ef0894115 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -10,6 +10,7 @@ @NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ EXTRA_DIST = +CLEANFILES = # nutclient.cpp for some legacy reason (maybe initial detached development?) # optionally includes "common.h" with the NUT build setup - and this option @@ -117,6 +118,30 @@ if HAVE_WINDOWS libupsclient_la_LDFLAGS += -no-undefined endif +# ./clients/libupsclient.la samples (partial!) on... +# Linux: +# # The name that we can dlopen(3). +# dlname='libupsclient.so.6' +# # Names of this library. +# library_names='libupsclient.so.6.0.1 libupsclient.so.6 libupsclient.so' +# # Directory that this library needs to be installed in: +# libdir='/usr/local/ups/lib' +# WIN32: +# dlname='libupsclient-6.dll' +# library_names='libupsclient.dll.a' +# libdir='//lib' +CLEANFILES += libupsclient-version.h +libupsclient-version.h: libupsclient.la + @SOFILE_LIBUPSCLIENT="`grep -E '^dlname' '$?' | sed -e 's/^[^=]*=//' -e 's/^\"\\(.*\\)\"/\\1/' -e 's/^'"'"'\\(.*\\)'"'"'/\\1/'`" \ + || SOFILE_LIBUPSCLIENT="" ; \ + if [ x"$${SOFILE_LIBUPSCLIENT-}" = x ] ; then \ + printf "#ifdef SOFILE_LIBUPSCLIENT\n# undef SOFILE_LIBUPSCLIENT\n#endif\n\n" ; \ + printf "#ifdef SOPATH_LIBUPSCLIENT\n# undef SOPATH_LIBUPSCLIENT\n#endif\n\n" ; \ + else \ + printf "#ifndef SOFILE_LIBUPSCLIENT\n# define SOFILE_LIBUPSCLIENT \"%s\"\n#endif\n\n" "$${SOFILE_LIBUPSCLIENT}" ; \ + printf "#ifndef SOPATH_LIBUPSCLIENT\n# define SOPATH_LIBUPSCLIENT \"%s/%s\"\n#endif\n\n" "@LIBDIR@" "$${SOFILE_LIBUPSCLIENT}" ; \ + fi > "$@" + if HAVE_CXX11 # libnutclient version information and build libnutclient_la_SOURCES = nutclient.h nutclient.cpp From 1d0a13210d92e0f6743c8ed974b9f3d216805e99 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 11:27:56 +0200 Subject: [PATCH 10/16] tools/nut-scanner/nutscan-init.c, tools/nut-scanner/Makefile.am, NEWS.adoc: use client/libupsclient-version.h for SOFILE_LIBUPSCLIENT/SOPATH_LIBUPSCLIENT [#2431] Signed-off-by: Jim Klimov --- NEWS.adoc | 4 ++-- tools/nut-scanner/Makefile.am | 12 ++++++++++-- tools/nut-scanner/nutscan-init.c | 29 +++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 25aa295e61..0ee525b938 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -142,8 +142,8 @@ https://github.com/networkupstools/nut/milestone/11 we can store and try to use the file name which was present on the build system, while we search for a suitable library. [#2431] + -NOTE: Currently both the long and short names for `libupsclient` should be -installed. +NOTE: A different but functionally equivalent trick is done for `libupsclient` +during a NUT build. * fixed support for IPv6 addresses (passed in square brackets) for both `-s` start/`-e` end command-line options, and for `-m cidr/mask` option. [issue #2512, PR #2518] diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am index a5bdd84372..78bab5633d 100644 --- a/tools/nut-scanner/Makefile.am +++ b/tools/nut-scanner/Makefile.am @@ -11,6 +11,8 @@ # Generally, list headers and/or sources which are re-generated # for nut-scanner in the parent dir +# Note there is also a libupsclient-version.h which we ensure and +# manage via usual `make` dependencies below. NUT_SCANNER_DEPS_H = nutscan-usb.h nutscan-snmp.h NUT_SCANNER_DEPS_C = @@ -28,6 +30,7 @@ $(NUT_SCANNER_DEPS): dummy # Make sure out-of-dir dependencies exist (especially when dev-building parts): $(top_builddir)/include/nut_version.h \ +$(top_builddir)/clients/libupsclient-version.h \ $(top_builddir)/common/libnutwincompat.la \ $(top_builddir)/drivers/libserial-nutscan.la \ $(top_builddir)/common/libcommonstr.la \ @@ -39,6 +42,7 @@ $(top_builddir)/common/libcommon.la: dummy # BUILT_SOURCES (in ../include) will ensure nut_version.h will # be built before anything else nut-scanner.c: $(top_builddir)/include/nut_version.h +nutscan-init.c: $(top_builddir)/clients/libupsclient-version.h # We optionally append values to this below bin_PROGRAMS = @@ -97,13 +101,17 @@ libnutscan_la_LDFLAGS += -version-info 2:6:0 # One solution to tackle if needed for those cases would be to make some # dynamic/shared libnutcommon (etc.) libnutscan_la_LDFLAGS += -export-symbols-regex '^(nutscan_|nut_debug_level|s_upsdebug|fatalx|fatal_with_errno|xcalloc|snprintfcat|max_threads|curr_threads|nut_report_config_flags|upsdebugx_report_search_paths|nut_prepare_search_paths)' -libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \ +libnutscan_la_CFLAGS = \ + -I$(top_builddir)/clients -I$(top_srcdir)/clients \ + -I$(top_builddir)/include -I$(top_srcdir)/include \ $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers libnutscan_la_LIBADD += $(top_builddir)/common/libcommonstr.la nut_scanner_SOURCES = nut-scanner.c -nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include +nut_scanner_CFLAGS = \ + -I$(top_builddir)/clients -I$(top_srcdir)/clients \ + -I$(top_builddir)/include -I$(top_srcdir)/include nut_scanner_LDADD = libnutscan.la if WITH_SSL diff --git a/tools/nut-scanner/nutscan-init.c b/tools/nut-scanner/nutscan-init.c index aad15c69d6..609c9a04d2 100644 --- a/tools/nut-scanner/nutscan-init.c +++ b/tools/nut-scanner/nutscan-init.c @@ -37,6 +37,11 @@ #include "nut_platform.h" #include "nut_stdint.h" +/* Note: generated during build in $(top_builddir)/clients/ + * and should be ensured to be here at the right moment by + * the nut-scanner Makefile. */ +#include "libupsclient-version.h" + #ifdef WIN32 # if defined HAVE_WINSOCK2_H && HAVE_WINSOCK2_H # include @@ -542,12 +547,22 @@ void nutscan_init(void) #endif /* WITH_FREEIPMI */ /* start of libupsclient for "old NUT" (vs. Avahi) protocol - unconditional */ +#ifdef SOFILE_LIBUPSCLIENT + if (!libname) { + libname = get_libname(SOFILE_LIBUPSCLIENT); + } +#endif /* SOFILE_LIBUPSCLIENT */ if (!libname) { libname = get_libname("libupsclient" SOEXT); } +#ifdef SOPATH_LIBUPSCLIENT + if (!libname) { + libname = get_libname(SOPATH_LIBUPSCLIENT); + } +#endif /* SOPATH_LIBUPSCLIENT */ #ifdef WIN32 - /* TODO: Detect DLL name at build time, or rename it at install time? */ - /* e.g. see clients/Makefile.am for version-info value */ + /* NOTE: Normally we should detect DLL name at build time, + * see clients/Makefile.am for libupsclient-version.h */ if (!libname) { libname = get_libname("libupsclient-6" SOEXT); } @@ -566,6 +581,11 @@ void nutscan_init(void) upsdebugx(1, "%s: get_libname() did not resolve libname for %s, " "trying to load it with libtool default resolver", __func__, "NUT Client library"); +#ifdef SOFILE_LIBUPSCLIENT + if (!nutscan_avail_nut) { + nutscan_avail_xml_http = nutscan_load_upsclient_library(SOFILE_LIBUPSCLIENT); + } +#endif /* SOFILE_LIBUPSCLIENT */ nutscan_avail_nut = nutscan_load_upsclient_library("libupsclient" SOEXT); #ifdef WIN32 if (!nutscan_avail_nut) { @@ -575,6 +595,11 @@ void nutscan_init(void) nutscan_avail_nut = nutscan_load_upsclient_library("libupsclient-3" SOEXT); } #endif /* WIN32 */ +#ifdef SOPATH_LIBUPSCLIENT + if (!nutscan_avail_nut) { + nutscan_avail_xml_http = nutscan_load_upsclient_library(SOPATH_LIBUPSCLIENT); + } +#endif /* SOFILE_LIBUPSCLIENT */ } upsdebugx(1, "%s: %s to load the library for %s", __func__, nutscan_avail_nut ? "succeeded" : "failed", "NUT Client library"); From a39ececaa9a48bb4017b7d330728c6ccda31dca7 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 13:39:00 +0000 Subject: [PATCH 11/16] clients/Makefile.am: dlname_filter(): use a shell function to avoid mixing backticks and double-quotes (upsets ksh) [#2431] Signed-off-by: Jim Klimov --- clients/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clients/Makefile.am b/clients/Makefile.am index 2ef0894115..bb5957984b 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -132,7 +132,8 @@ endif # libdir='//lib' CLEANFILES += libupsclient-version.h libupsclient-version.h: libupsclient.la - @SOFILE_LIBUPSCLIENT="`grep -E '^dlname' '$?' | sed -e 's/^[^=]*=//' -e 's/^\"\\(.*\\)\"/\\1/' -e 's/^'"'"'\\(.*\\)'"'"'/\\1/'`" \ + @dlname_filter() { sed -e 's/^[^=]*=//' -e 's/^"\(.*\)"$$/\1/' -e 's/^'"'"'\(.*\)'"'"'$$/\1/' ; }; \ + SOFILE_LIBUPSCLIENT="`grep -E '^dlname' '$?' | dlname_filter`" \ || SOFILE_LIBUPSCLIENT="" ; \ if [ x"$${SOFILE_LIBUPSCLIENT-}" = x ] ; then \ printf "#ifdef SOFILE_LIBUPSCLIENT\n# undef SOFILE_LIBUPSCLIENT\n#endif\n\n" ; \ From 166f5808c4f5e2c3dc63885cfdef60070a3ea2b6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 13:51:27 +0000 Subject: [PATCH 12/16] README.adoc: reword the GitHub stars image Signed-off-by: Jim Klimov --- README.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index c507647fd5..d5b50b5baf 100644 --- a/README.adoc +++ b/README.adoc @@ -212,12 +212,12 @@ alive and in need of power protection, they should be able to get it. ===== If you like how the NUT project helps protect your systems from power outages, please consider sponsoring or at least "starring" it on GitHub at -https://github.com/networkupstools/nut/ - these stars are among metrics +https://github.com/networkupstools/nut/ -- these stars are among metrics which the larger potential sponsors consider when choosing how to help FOSS projects. Keeping the lights shining in such a large non-regression build matrix is a big undertaking! -image:https://api.star-history.com/svg?repos=networkupstools/nut&type=Date[link="https://star-history.com/#networkupstools/nut&Date" alt="Star History Chart"] +image:https://api.star-history.com/svg?repos=networkupstools/nut&type=Date[link="https://star-history.com/#networkupstools/nut&Date" alt="NUT GitHub Star History Chart"] See <> for an overview of the shared effort. From f27f2f4b5dcfa48f8ab541f86b367f1aa3f785b3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 13:52:28 +0000 Subject: [PATCH 13/16] docs/nut.dict, docs/man/hwmon_ina219.txt: update for OI aspell dictionaries Signed-off-by: Jim Klimov --- docs/man/hwmon_ina219.txt | 2 +- docs/nut.dict | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/man/hwmon_ina219.txt b/docs/man/hwmon_ina219.txt index 84510dd5c8..9cf8394186 100644 --- a/docs/man/hwmon_ina219.txt +++ b/docs/man/hwmon_ina219.txt @@ -41,7 +41,7 @@ Optional parameters: Threshold for low battery state (in percent). *default.battery.voltage.nominal*='voltage-value':: -Nominal voltage (V) value of utilised batteries, used to derive their low +Nominal voltage (V) value of utilized batteries, used to derive their low and high watermark settings (see below). Default: 3.6. + Known pre-sets include: `3.6`, `3.7`, `3.8`, `3.85`. diff --git a/docs/nut.dict b/docs/nut.dict index 6c170fd239..24717acf50 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3189 utf-8 +personal_ws-1.1 en 3190 utf-8 AAC AAS ABI @@ -979,6 +979,7 @@ REPLBATT REQSSL RETPCT REXX +RISC RK RMCARD RMCPplus From 79d16074932087a1e61df0a928bb22e23151ed72 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 17:53:52 +0200 Subject: [PATCH 14/16] README.adoc: make "NUT GitHub Star History Chart" visible only in GitHub/HTML auto-rendering but not in static PDF docs Signed-off-by: Jim Klimov --- README.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.adoc b/README.adoc index d5b50b5baf..6b6bf88a45 100644 --- a/README.adoc +++ b/README.adoc @@ -217,7 +217,9 @@ which the larger potential sponsors consider when choosing how to help FOSS projects. Keeping the lights shining in such a large non-regression build matrix is a big undertaking! +ifndef::pdf_format[] image:https://api.star-history.com/svg?repos=networkupstools/nut&type=Date[link="https://star-history.com/#networkupstools/nut&Date" alt="NUT GitHub Star History Chart"] +endif::pdf_format[] See <> for an overview of the shared effort. From f21c771b643be6c415c486b93f7dfb6c942d010e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 18:14:44 +0200 Subject: [PATCH 15/16] README.adoc: avoid double-dash in the TIP block, this somehow breaks PDF generation Signed-off-by: Jim Klimov --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 6b6bf88a45..9bbbca12d7 100644 --- a/README.adoc +++ b/README.adoc @@ -212,7 +212,7 @@ alive and in need of power protection, they should be able to get it. ===== If you like how the NUT project helps protect your systems from power outages, please consider sponsoring or at least "starring" it on GitHub at -https://github.com/networkupstools/nut/ -- these stars are among metrics +https://github.com/networkupstools/nut/ - these stars are among metrics which the larger potential sponsors consider when choosing how to help FOSS projects. Keeping the lights shining in such a large non-regression build matrix is a big undertaking! From 7108b638c0152228ef33d9f225d44522951d59ea Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 15 Jul 2024 18:50:24 +0200 Subject: [PATCH 16/16] docs/Makefile.am: clarify the message about DOC-CHANGELOG-GENERATE-WRAPPER to differentiate it better from the real build [#2510] Signed-off-by: Jim Klimov --- docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index 79a67348c6..619d9e6778 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -334,7 +334,7 @@ DOCBUILD_CONVERT_GITHUB_LINKS = { \ dummy: $(top_builddir)/ChangeLog: dummy - +@echo " DOC-CHANGELOG-GENERATE $@ : call parent Makefile" \ + @+echo " DOC-CHANGELOG-GENERATE-WRAPPER $@ : call parent Makefile to decide if (re-)generation is needed" \ && cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) $(@F) # BSD Make dislikes the path resolution here and does not always populate "$<"