Imported Upstream version 2.6.4
This commit is contained in:
		
							parent
							
								
									fad6ced6f6
								
							
						
					
					
						commit
						fefe62b2bd
					
				
					 257 changed files with 6020 additions and 1394 deletions
				
			
		|  | @ -11,7 +11,7 @@ endif | |||
| libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \ | ||||
| 	nutscan-device.c nutscan-ip.c nutscan-display.c nutscan-init.c \ | ||||
| 	scan_usb.c scan_snmp.c scan_xml_http.c scan_avahi.c | ||||
| libnutscan_la_LIBADD = ../../clients/libupsclient.la $(NETLIBS) $(LIBLTDL_LIBS) | ||||
| libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) | ||||
| libnutscan_la_LDFLAGS = -version-info 1:0:0 | ||||
| libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include $(LIBLTDL_CFLAGS) | ||||
| 
 | ||||
|  |  | |||
|  | @ -105,9 +105,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ | |||
| LTLIBRARIES = $(lib_LTLIBRARIES) | ||||
| am__DEPENDENCIES_1 = | ||||
| @WITH_SSL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) | ||||
| libnutscan_la_DEPENDENCIES = ../../clients/libupsclient.la \
 | ||||
| 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
 | ||||
| 	$(am__DEPENDENCIES_2) | ||||
| libnutscan_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 | ||||
| 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) | ||||
| am_libnutscan_la_OBJECTS = libnutscan_la-scan_nut.lo \
 | ||||
| 	libnutscan_la-scan_ipmi.lo libnutscan_la-nutscan-device.lo \
 | ||||
| 	libnutscan_la-nutscan-ip.lo libnutscan_la-nutscan-display.lo \
 | ||||
|  | @ -229,6 +228,7 @@ MKDIR_P = @MKDIR_P@ | |||
| NETLIBS = @NETLIBS@ | ||||
| NM = @NM@ | ||||
| NMEDIT = @NMEDIT@ | ||||
| NUT_NETVERSION = @NUT_NETVERSION@ | ||||
| OBJDUMP = @OBJDUMP@ | ||||
| OBJEXT = @OBJEXT@ | ||||
| OS_NAME = @OS_NAME@ | ||||
|  | @ -242,6 +242,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ | |||
| PACKAGE_URL = @PACKAGE_URL@ | ||||
| PACKAGE_VERSION = @PACKAGE_VERSION@ | ||||
| PATH_SEPARATOR = @PATH_SEPARATOR@ | ||||
| PIDPATH = @PIDPATH@ | ||||
| PKG_CONFIG = @PKG_CONFIG@ | ||||
| PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ | ||||
| PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ | ||||
|  | @ -249,6 +250,7 @@ PORT = @PORT@ | |||
| RANLIB = @RANLIB@ | ||||
| RUN_AS_GROUP = @RUN_AS_GROUP@ | ||||
| RUN_AS_USER = @RUN_AS_USER@ | ||||
| SBINDIR = @SBINDIR@ | ||||
| SED = @SED@ | ||||
| SERLIBS = @SERLIBS@ | ||||
| SET_MAKE = @SET_MAKE@ | ||||
|  | @ -328,8 +330,7 @@ libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \ | |||
| 	nutscan-device.c nutscan-ip.c nutscan-display.c nutscan-init.c \
 | ||||
| 	scan_usb.c scan_snmp.c scan_xml_http.c scan_avahi.c | ||||
| 
 | ||||
| libnutscan_la_LIBADD = ../../clients/libupsclient.la $(NETLIBS) \
 | ||||
| 	$(LIBLTDL_LIBS) $(am__append_2) | ||||
| libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) $(am__append_2) | ||||
| libnutscan_la_LDFLAGS = -version-info 1:0:0 | ||||
| libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \
 | ||||
| 	$(LIBLTDL_CFLAGS) $(am__append_1) $(am__append_3) \
 | ||||
|  |  | |||
|  | @ -470,5 +470,8 @@ display_help: | |||
| 
 | ||||
| 	display_func(dev[TYPE_IPMI]); | ||||
| 	nutscan_free_device(dev[TYPE_IPMI]); | ||||
| 
 | ||||
| 	nutscan_free(); | ||||
| 
 | ||||
| 	return EXIT_SUCCESS; | ||||
| } | ||||
|  |  | |||
|  | @ -18,10 +18,11 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "common.h" | ||||
| #include <ltdl.h> | ||||
| 
 | ||||
| int nutscan_avail_avahi = 0; | ||||
| int nutscan_avail_ipmi = 0; | ||||
| int nutscan_avail_nut = 1; | ||||
| int nutscan_avail_nut = 0; | ||||
| int nutscan_avail_snmp = 0; | ||||
| int nutscan_avail_usb = 0; | ||||
| int nutscan_avail_xml_http = 0; | ||||
|  | @ -31,6 +32,7 @@ int nutscan_load_snmp_library(void); | |||
| int nutscan_load_neon_library(void); | ||||
| int nutscan_load_avahi_library(void); | ||||
| int nutscan_load_ipmi_library(void); | ||||
| int nutscan_load_upsclient_library(void); | ||||
| 
 | ||||
| void nutscan_init(void) | ||||
| { | ||||
|  | @ -49,4 +51,27 @@ void nutscan_init(void) | |||
| #ifdef WITH_FREEIPMI | ||||
| 	nutscan_avail_ipmi = nutscan_load_ipmi_library(); | ||||
| #endif | ||||
| 	nutscan_avail_nut = nutscan_load_upsclient_library(); | ||||
| } | ||||
| 
 | ||||
| void nutscan_free(void) | ||||
| { | ||||
| 	if( nutscan_avail_usb ) { | ||||
| 		lt_dlexit(); | ||||
| 	} | ||||
| 	if( nutscan_avail_snmp ) { | ||||
| 		lt_dlexit(); | ||||
| 	} | ||||
| 	if( nutscan_avail_xml_http ) { | ||||
| 		lt_dlexit(); | ||||
| 	} | ||||
| 	if( nutscan_avail_avahi ) { | ||||
| 		lt_dlexit(); | ||||
| 	} | ||||
| 	if( nutscan_avail_ipmi ) { | ||||
| 		lt_dlexit(); | ||||
| 	} | ||||
| 	if( nutscan_avail_nut ) { | ||||
| 		lt_dlexit(); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -27,4 +27,5 @@ extern int nutscan_avail_usb; | |||
| extern int nutscan_avail_xml_http; | ||||
| 
 | ||||
| void nutscan_init(void); | ||||
| void nutscan_free(void); | ||||
| #endif | ||||
|  |  | |||
|  | @ -38,7 +38,7 @@ static snmp_device_id_t snmp_device_table[] = { | |||
| 	{ ".1.3.6.1.4.1.318.1.1.1.1.1.1.0" ,  "apcc", NULL}, | ||||
| 	{ ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1" ,  "baytech", NULL}, | ||||
| 	{ ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0" ,  "cyberpower", ".1.3.6.1.4.1.3808"}, | ||||
| 	{ "1.3.6.1.4.1.232.165.3.1.1.0" ,  "cpqpower", NULL}, | ||||
| 	{ ".1.3.6.1.4.1.232.165.3.1.1.0" ,  "cpqpower", ".1.3.6.1.4.1.232.165.3"}, | ||||
| 	{ ".1.3.6.1.4.1.4555.1.1.1.1.1.1.0" ,  "netvision", ".1.3.6.1.4.1.4555.1.1.1"}, | ||||
|         /* Terminating entry */ | ||||
|         { NULL, NULL, NULL} | ||||
|  |  | |||
|  | @ -32,6 +32,7 @@ typedef struct { | |||
| static usb_device_id_t usb_device_table[] = { | ||||
| 
 | ||||
| 	{ 0x0001, 0x0000, "blazer_usb" }, | ||||
| 	{ 0x03f0, 0x0001, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1f01, "bcmxcp_usb" }, | ||||
| 	{ 0x03f0, 0x1f02, "bcmxcp_usb" }, | ||||
| 	{ 0x03f0, 0x1f06, "usbhid-ups" }, | ||||
|  | @ -40,6 +41,12 @@ static usb_device_id_t usb_device_table[] = { | |||
| 	{ 0x03f0, 0x1f0a, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe0, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe1, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe2, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe3, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe5, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe6, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe7, "usbhid-ups" }, | ||||
| 	{ 0x03f0, 0x1fe8, "usbhid-ups" }, | ||||
| 	{ 0x0463, 0x0001, "usbhid-ups" }, | ||||
| 	{ 0x0463, 0xffff, "usbhid-ups" }, | ||||
| 	{ 0x047c, 0xffff, "usbhid-ups" }, | ||||
|  | @ -58,8 +65,11 @@ static usb_device_id_t usb_device_table[] = { | |||
| 	{ 0x0592, 0x0004, "usbhid-ups" }, | ||||
| 	{ 0x05b8, 0x0000, "blazer_usb" }, | ||||
| 	{ 0x0665, 0x5161, "blazer_usb" }, | ||||
| 	{ 0x06da, 0x0002, "bcmxcp_usb" }, | ||||
| 	{ 0x06da, 0x0002, "blazer_usb" }, | ||||
| 	{ 0x06da, 0x0003, "blazer_usb" }, | ||||
| 	{ 0x06da, 0x0004, "blazer_usb" }, | ||||
| 	{ 0x06da, 0x0005, "blazer_usb" }, | ||||
| 	{ 0x06da, 0x0201, "blazer_usb" }, | ||||
| 	{ 0x06da, 0xffff, "usbhid-ups" }, | ||||
| 	{ 0x075d, 0x0300, "usbhid-ups" }, | ||||
| 	{ 0x0764, 0x0005, "usbhid-ups" }, | ||||
|  |  | |||
|  | @ -36,6 +36,7 @@ | |||
| #include <ltdl.h> | ||||
| 
 | ||||
| /* dynamic link library stuff */ | ||||
| static char * libname = "libavahi-client"; | ||||
| static lt_dlhandle dl_handle = NULL; | ||||
| static const char *dl_error = NULL; | ||||
| 
 | ||||
|  | @ -98,7 +99,7 @@ int nutscan_load_avahi_library() | |||
|                 return 0; | ||||
|         } | ||||
| 
 | ||||
|         dl_handle = lt_dlopenext("libavahi-client"); | ||||
|         dl_handle = lt_dlopenext(libname); | ||||
|         if (!dl_handle) { | ||||
|                 dl_error = lt_dlerror(); | ||||
|                 goto err; | ||||
|  | @ -196,8 +197,10 @@ int nutscan_load_avahi_library() | |||
| 
 | ||||
|         return 1; | ||||
| err: | ||||
|         fprintf(stderr, "%s\n", dl_error); | ||||
|         fprintf(stderr, "Cannot load AVAHI library (%s) : %s. AVAHI search disabled.\n", libname, dl_error); | ||||
| 
 | ||||
|         dl_handle = (void *)1; | ||||
| 	lt_dlexit(); | ||||
|         return 0; | ||||
| } | ||||
| /* end of dynamic link library stuff */ | ||||
|  |  | |||
|  | @ -29,6 +29,7 @@ | |||
| #define NUT_IPMI_DRV_NAME	"nut-ipmipsu" | ||||
| 
 | ||||
| /* dynamic link library stuff */ | ||||
| static char * libname = "libfreeipmi"; | ||||
| static lt_dlhandle dl_handle = NULL; | ||||
| static const char *dl_error = NULL; | ||||
| 
 | ||||
|  | @ -77,7 +78,7 @@ int nutscan_load_ipmi_library() | |||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	dl_handle = lt_dlopenext("libfreeipmi"); | ||||
| 	dl_handle = lt_dlopenext(libname); | ||||
| 	if (!dl_handle) { | ||||
| 		dl_error = lt_dlerror(); | ||||
| 		goto err; | ||||
|  | @ -163,8 +164,9 @@ int nutscan_load_ipmi_library() | |||
| 
 | ||||
| 	return 1; | ||||
| err: | ||||
| 	fprintf(stderr, "%s\n", dl_error); | ||||
|         fprintf(stderr, "Cannot load IPMI library (%s) : %s. IPMI search disabled.\n", libname, dl_error); | ||||
| 	dl_handle = (void *)1; | ||||
| 	lt_dlexit(); | ||||
| 	return 0; | ||||
| } | ||||
| /* end of dynamic link library stuff */ | ||||
|  |  | |||
|  | @ -23,7 +23,20 @@ | |||
| #ifdef HAVE_PTHREAD | ||||
| #include <pthread.h> | ||||
| #endif | ||||
| #include <ltdl.h> | ||||
| 
 | ||||
| /* dynamic link library stuff */ | ||||
| static char * libname = "libupsclient"; | ||||
| static lt_dlhandle dl_handle = NULL; | ||||
| static const char *dl_error = NULL; | ||||
| 
 | ||||
| static int (*nut_upscli_splitaddr)(const char *buf,char **hostname, int *port); | ||||
| static int (*nut_upscli_tryconnect)(UPSCONN_t *ups, const char *host, int port, | ||||
| 					int flags,struct timeval * timeout); | ||||
| static int (*nut_upscli_list_start)(UPSCONN_t *ups, unsigned int numq, | ||||
| 					const char **query); | ||||
| static int (*nut_upscli_list_next)(UPSCONN_t *ups, unsigned int numq, | ||||
| 			const char **query,unsigned int *numa, char ***answer); | ||||
| 
 | ||||
| static nutscan_device_t * dev_ret = NULL; | ||||
| #ifdef HAVE_PTHREAD | ||||
|  | @ -35,6 +48,64 @@ struct scan_nut_arg { | |||
| 	long timeout; | ||||
| }; | ||||
| 
 | ||||
| /* return 0 on error */ | ||||
| int nutscan_load_upsclient_library() | ||||
| { | ||||
| 
 | ||||
|         if( dl_handle != NULL ) { | ||||
|                 /* if previous init failed */ | ||||
|                 if( dl_handle == (void *)1 ) { | ||||
|                         return 0; | ||||
|                 } | ||||
|                 /* init has already been done */ | ||||
|                 return 1; | ||||
|         } | ||||
| 
 | ||||
|         if( lt_dlinit() != 0 ) { | ||||
|                 fprintf(stderr, "Error initializing lt_init\n"); | ||||
|                 return 0; | ||||
|         } | ||||
| 
 | ||||
|         dl_handle = lt_dlopenext(libname); | ||||
|         if (!dl_handle) { | ||||
|                 dl_error = lt_dlerror(); | ||||
|                 goto err; | ||||
|         } | ||||
| 
 | ||||
|         lt_dlerror();      /* Clear any existing error */ | ||||
| 
 | ||||
|         *(void **) (&nut_upscli_splitaddr) = lt_dlsym(dl_handle, | ||||
|                                                         "upscli_splitaddr"); | ||||
|         if ((dl_error = lt_dlerror()) != NULL)  { | ||||
|                 goto err; | ||||
|         } | ||||
| 
 | ||||
|         *(void **) (&nut_upscli_tryconnect) = lt_dlsym(dl_handle, | ||||
| 							"upscli_tryconnect"); | ||||
|         if ((dl_error = lt_dlerror()) != NULL)  { | ||||
|                 goto err; | ||||
|         } | ||||
| 
 | ||||
|         *(void **) (&nut_upscli_list_start) = lt_dlsym(dl_handle, | ||||
| 							"upscli_list_start"); | ||||
|         if ((dl_error = lt_dlerror()) != NULL)  { | ||||
|                 goto err; | ||||
|         } | ||||
| 
 | ||||
|         *(void **) (&nut_upscli_list_next) = lt_dlsym(dl_handle, | ||||
| 							"upscli_list_next"); | ||||
|         if ((dl_error = lt_dlerror()) != NULL)  { | ||||
|                 goto err; | ||||
|         } | ||||
| 
 | ||||
|         return 1; | ||||
| err: | ||||
|         fprintf(stderr, "Cannot load NUT library (%s) : %s. NUT search disabled.\n", libname, dl_error); | ||||
|         dl_handle = (void *)1; | ||||
| 	lt_dlexit(); | ||||
|         return 0; | ||||
| } | ||||
| 
 | ||||
| /* FIXME: SSL support */ | ||||
| static void * list_nut_devices(void * arg) | ||||
| { | ||||
|  | @ -56,28 +127,32 @@ static void * list_nut_devices(void * arg) | |||
| 	query[0] = "UPS"; | ||||
| 	numq = 1; | ||||
| 
 | ||||
| 	if (upscli_splitaddr(target_hostname, &hostname, &port) != 0) { | ||||
| 	if ((*nut_upscli_splitaddr)(target_hostname, &hostname, &port) != 0) { | ||||
| 		free(target_hostname); | ||||
| 		free(nut_arg); | ||||
| 		free(ups); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	if (upscli_tryconnect(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) { | ||||
| 	if ((*nut_upscli_tryconnect)(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) { | ||||
| 		free(target_hostname); | ||||
| 		free(nut_arg); | ||||
| 		free(ups); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	if(upscli_list_start(ups, numq, query) < 0) { | ||||
| 	if((*nut_upscli_list_start)(ups, numq, query) < 0) { | ||||
| 		free(target_hostname); | ||||
| 		free(nut_arg); | ||||
| 		free(ups); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	while (upscli_list_next(ups, numq, query, &numa, &answer) == 1) { | ||||
| 	while ((*nut_upscli_list_next)(ups,numq, query, &numa, &answer) == 1) { | ||||
| 		/* UPS <upsname> <description> */ | ||||
| 		if (numa < 3) { | ||||
| 			free(target_hostname); | ||||
| 			free(nut_arg); | ||||
| 			free(ups); | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		/* FIXME: check for duplication by getting driver.port and device.serial
 | ||||
|  | @ -109,6 +184,7 @@ static void * list_nut_devices(void * arg) | |||
| 
 | ||||
| 	free(target_hostname); | ||||
| 	free(nut_arg); | ||||
| 	free(ups); | ||||
| 	return NULL; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -56,19 +56,25 @@ | |||
| #endif | ||||
| #include "nutscan-snmp.h" | ||||
| 
 | ||||
| /* Address API change */ | ||||
| #ifndef usmAESPrivProtocol | ||||
| #define USMAESPRIVPROTOCOL "usmAES128PrivProtocol" | ||||
| #else | ||||
| #define USMAESPRIVPROTOCOL "usmAESPrivProtocol" | ||||
| #endif | ||||
| 
 | ||||
| #define SysOID ".1.3.6.1.2.1.1.2.0" | ||||
| 
 | ||||
| static nutscan_device_t * dev_ret = NULL; | ||||
| #ifdef HAVE_PTHREAD | ||||
| static pthread_mutex_t dev_mutex; | ||||
| static pthread_mutex_t lib_mutex; | ||||
| static pthread_t * thread_array = NULL; | ||||
| static int thread_count = 0; | ||||
| #endif | ||||
| long g_usec_timeout ; | ||||
| 
 | ||||
| /* dynamic link library stuff */ | ||||
| static char * libname = "libnetsnmp"; | ||||
| static lt_dlhandle dl_handle = NULL; | ||||
| static const char *dl_error = NULL; | ||||
| 
 | ||||
|  | @ -99,10 +105,6 @@ static oid * (*nut_usmDESPrivProtocol); | |||
| /* return 0 on error */ | ||||
| int nutscan_load_snmp_library() | ||||
| { | ||||
| #ifdef HAVE_PTHREAD | ||||
| 	pthread_mutex_lock(&lib_mutex); | ||||
| #endif | ||||
| 
 | ||||
| 	if( dl_handle != NULL ) { | ||||
| 		/* if previous init failed */ | ||||
| 		if( dl_handle == (void *)1 ) { | ||||
|  | @ -117,7 +119,7 @@ int nutscan_load_snmp_library() | |||
|                 return 0; | ||||
|         } | ||||
| 
 | ||||
| 	dl_handle = lt_dlopenext("libnetsnmp"); | ||||
| 	dl_handle = lt_dlopenext(libname); | ||||
| 	if (!dl_handle) { | ||||
| 		dl_error = lt_dlerror(); | ||||
| 		goto err; | ||||
|  | @ -205,7 +207,7 @@ int nutscan_load_snmp_library() | |||
| 	} | ||||
| 
 | ||||
| 	*(void **) (&nut_usmAESPrivProtocol) = lt_dlsym(dl_handle, | ||||
| 							"usmAESPrivProtocol"); | ||||
| 							USMAESPRIVPROTOCOL); | ||||
| 	if ((dl_error = lt_dlerror()) != NULL)  { | ||||
| 		goto err; | ||||
| 	} | ||||
|  | @ -228,16 +230,11 @@ int nutscan_load_snmp_library() | |||
| 		goto err; | ||||
| 	} | ||||
| 
 | ||||
| #ifdef HAVE_PTHREAD | ||||
| 	pthread_mutex_unlock(&dev_mutex); | ||||
| #endif | ||||
| 	return 1; | ||||
| err: | ||||
| 	fprintf(stderr, "%s\n", dl_error); | ||||
|         fprintf(stderr, "Cannot load SNMP library (%s) : %s. SNMP search disabled.\n", libname, dl_error); | ||||
| 	dl_handle = (void *)1; | ||||
| #ifdef HAVE_PTHREAD | ||||
| 	pthread_mutex_unlock(&dev_mutex); | ||||
| #endif | ||||
| 	lt_dlexit(); | ||||
| 	return 0; | ||||
| } | ||||
| /* end of dynamic link library stuff */ | ||||
|  | @ -660,7 +657,6 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip | |||
| 	pthread_t thread; | ||||
| 
 | ||||
| 	pthread_mutex_init(&dev_mutex,NULL); | ||||
| 	pthread_mutex_init(&lib_mutex,NULL); | ||||
| #endif | ||||
| 
 | ||||
|         if( !nutscan_avail_snmp ) { | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ | |||
| #include <ltdl.h> | ||||
| 
 | ||||
| /* dynamic link library stuff */ | ||||
| static char * libname = "libusb"; | ||||
| static lt_dlhandle dl_handle = NULL; | ||||
| static const char *dl_error = NULL; | ||||
| static int (*nut_usb_close)(usb_dev_handle *dev); | ||||
|  | @ -57,7 +58,7 @@ int nutscan_load_usb_library() | |||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
|         dl_handle = lt_dlopenext("libusb"); | ||||
|         dl_handle = lt_dlopenext(libname); | ||||
|         if (!dl_handle) { | ||||
|                 dl_error = lt_dlerror(); | ||||
|                 goto err; | ||||
|  | @ -106,8 +107,9 @@ int nutscan_load_usb_library() | |||
| 
 | ||||
|         return 1; | ||||
| err: | ||||
|         fprintf(stderr, "%s\n", dl_error); | ||||
|         fprintf(stderr, "Cannot load USB library (%s) : %s. USB search disabled.\n", libname, dl_error); | ||||
|         dl_handle = (void *)1; | ||||
| 	lt_dlexit(); | ||||
|         return 0; | ||||
| } | ||||
| /* end of dynamic link library stuff */ | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ | |||
| #include <ltdl.h> | ||||
| 
 | ||||
| /* dynamic link library stuff */ | ||||
| static char * libname = "libneon"; | ||||
| static lt_dlhandle dl_handle = NULL; | ||||
| static const char *dl_error = NULL; | ||||
| 
 | ||||
|  | @ -63,7 +64,7 @@ int nutscan_load_neon_library() | |||
|                 return 0; | ||||
|         } | ||||
| 
 | ||||
|         dl_handle = lt_dlopenext("libneon"); | ||||
|         dl_handle = lt_dlopenext(libname); | ||||
|         if (!dl_handle) { | ||||
|                 dl_error = lt_dlerror(); | ||||
|                 goto err; | ||||
|  | @ -93,8 +94,9 @@ int nutscan_load_neon_library() | |||
| 
 | ||||
|         return 1; | ||||
| err: | ||||
|         fprintf(stderr, "%s\n", dl_error); | ||||
|         fprintf(stderr, "Cannot load XML library (%s) : %s. XML search disabled.\n", libname, dl_error); | ||||
|         dl_handle = (void *)1; | ||||
| 	lt_dlexit(); | ||||
|         return 0; | ||||
| } | ||||
| 
 | ||||
|  | @ -210,7 +212,7 @@ nutscan_device_t * nutscan_scan_xml_http(long usec_timeout) | |||
| 				ne_xml_parser *parser = (*nut_ne_xml_create)(); | ||||
| 				(*nut_ne_xml_push_handler)(parser, startelm_cb, | ||||
| 							NULL, NULL, nut_dev); | ||||
| 				(*nut_ne_xml_parse)(parser, buf, strlen(buf)); | ||||
| 				(*nut_ne_xml_parse)(parser, buf, recv_size); | ||||
| 				(*nut_ne_xml_destroy)(parser); | ||||
| 
 | ||||
| 				nut_dev->driver = strdup("netxml-ups"); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue