|o||GET NUMLOGINS <ups>|
o GET UPSDESC <ups>
o GET VAR <ups> <var>
o GET TYPE <ups> <var>
o GET DESC <ups> <var>
o GET CMDDESC <ups> <cmd>
To generate a request for GET NUMLOGINS su700, you would populate query and numq as follows:
unsigned int numq; const char *query;
query = "NUMLOGINS"; query = "su700"; numq = 2;
All escaping of special characters and quoting of elements with spaces is handled for you inside this function.
The raw response from upsd to the above query would be NUMLOGINS su700 1. Since this is split up for you, the values work out like this:
unsigned int numa;
numa = 3; answer = "NUMLOGINS" answer = "su700" answer = "1"
Notice that the value which you seek typically starts at answer[numq].
This function will check your query against the response from upsd(8). For example, if you send "VAR" "su700" "ups.status", it will expect to see those at the beginning of the response.
If the results from upsd do not pass this case-insensitive test against your request, this function will return an error. When this happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL.
The pointers contained within the answer array are only valid until the next call to a upsclient function which references them. If you need to use data from multiple calls, you must copy it somewhere else first.
The answer array and its elements may change locations, so you must not rely on previous addresses. You must only use the addresses which were returned by the most recent call. You also must not attempt to use more than numa elements in answer. Such behavior is undefined, and may yield bogus data or a crash.
The array will be deleted after calling upscli_disconnect(3). Any access after that point is also undefined.
The upscli_get() function returns 0 on success, or -1 if an error occurs.
If upsd disconnects, you may need to handle or ignore SIGPIPE in order to prevent your program from terminating the next time that the library writes to the disconnected socket. The following code in your initialization function will allow the upscli_get() call to return an error in that case:
#include <signal.h> ... signal (SIGPIPE, SIG_IGN); ...
upscli_list_start(3), upscli_list_next(3), upscli_strerror(3), upscli_upserror(3)
|Network UPS Tools 2&.7&.3&.||UPSCLI_GET (3)||03/02/2016|