Imported Upstream version 2.7.1
This commit is contained in:
parent
a1fa151fc7
commit
0121794af9
451 changed files with 41339 additions and 10887 deletions
|
@ -37,6 +37,7 @@ 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 int (*nut_upscli_disconnect)(UPSCONN_t *ups);
|
||||
|
||||
static nutscan_device_t * dev_ret = NULL;
|
||||
#ifdef HAVE_PTHREAD
|
||||
|
@ -98,6 +99,12 @@ int nutscan_load_upsclient_library()
|
|||
goto err;
|
||||
}
|
||||
|
||||
*(void **) (&nut_upscli_disconnect) = lt_dlsym(dl_handle,
|
||||
"upscli_disconnect");
|
||||
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);
|
||||
|
@ -133,6 +140,7 @@ static void * list_nut_devices(void * arg)
|
|||
free(ups);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((*nut_upscli_tryconnect)(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) {
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
|
@ -141,6 +149,7 @@ static void * list_nut_devices(void * arg)
|
|||
}
|
||||
|
||||
if((*nut_upscli_list_start)(ups, numq, query) < 0) {
|
||||
(*nut_upscli_disconnect)(ups);
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
|
@ -150,6 +159,7 @@ static void * list_nut_devices(void * arg)
|
|||
while ((*nut_upscli_list_next)(ups,numq, query, &numa, &answer) == 1) {
|
||||
/* UPS <upsname> <description> */
|
||||
if (numa < 3) {
|
||||
(*nut_upscli_disconnect)(ups);
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
|
@ -164,7 +174,7 @@ static void * list_nut_devices(void * arg)
|
|||
dev = nutscan_new_device();
|
||||
dev->type = TYPE_NUT;
|
||||
dev->driver = strdup("nutclient");
|
||||
/* +1+1 is for '@' character and terminnating 0 */
|
||||
/* +1+1 is for '@' character and terminating 0 */
|
||||
buf_size = strlen(answer[1])+strlen(hostname)+1+1;
|
||||
dev->port = malloc(buf_size);
|
||||
if( dev->port ) {
|
||||
|
@ -182,6 +192,7 @@ static void * list_nut_devices(void * arg)
|
|||
}
|
||||
}
|
||||
|
||||
(*nut_upscli_disconnect)(ups);
|
||||
free(target_hostname);
|
||||
free(nut_arg);
|
||||
free(ups);
|
||||
|
@ -269,5 +280,5 @@ nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, con
|
|||
signal(SIGPIPE,SIG_DFL);
|
||||
}
|
||||
|
||||
return dev_ret;
|
||||
return nutscan_rewind_device(dev_ret);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue