Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

upsclient(3) [posix man page]

UPSCLIENT(3)							    NUT Manual							      UPSCLIENT(3)

NAME
upsclient - Network UPS Tools client access library DESCRIPTION
The Network UPS Tools (NUT) upsclient library provides a number of useful functions for programs to use when communicating with upsd(8). Many of the low-level socket and protocol details are handled automatically when using this interface. State is maintained across calls in an opaque structure called UPSCONN_t. Callers are expected to create one per connection. These will be provided to most of the upsclient functions. The format of this structure is subject to change, and client programs must not reference elements within it directly. NETWORK FUNCTIONS
To create a new connection, use upscli_connect(3). This will also initialize the UPSCONN_t structure. To verify that a connection has been established later, upscli_fd(3) can be used to return the file descriptor. Clients wishing to check for the presence and operation of SSL on a connection may call upscli_ssl(3). The majority of clients will use upscli_get(3) to retrieve single items from the server. To retrieve a list, use upscli_list_start(3) to get it started, then call upscli_list_next(3) for each element. Raw lines of text may be sent to upsd(8) with upscli_sendline(3). Reading raw lines is possible with upscli_readline(3). Client programs are expected to format these lines according to the protocol, as no checking will be performed before transmission. At the end of a connection, you must call upsclient_disconnect(3) to disconnect from upsd and release any dynamic memory associated with the UPSCONN_t structure. Failure to call this function will result in memory and file descriptor leaks in your program. ERROR HANDLING
In the event of an error, upscli_strerror(3) will provide human-readable details on what happened. upscli_upserror(3) may also be used to retrieve the error number. These numbers are defined in upsclient.h as UPSCLI_ERR_*. SEE ALSO
libupsclient-config(1), upscli_connect(3), upscli_disconnect(3), upscli_fd(3), upscli_getvar(3), upscli_list_next(3), upscli_list_start(3), upscli_readline(3), upscli_sendline(3), upscli_splitaddr(3), upscli_splitname(3), upscli_ssl(3), upscli_strerror(3), upscli_upserror(3) Network UPS Tools 05/22/2012 UPSCLIENT(3)

Check Out this Related Man Page

UPSCLI_LIST_START(3)						    NUT Manual						      UPSCLI_LIST_START(3)

NAME
upscli_list_start - begin multi-item retrieval from a UPS SYNOPSIS
#include <upsclient.h> int upscli_list_start(UPSCONN_t *ups, int numq, const char **query) DESCRIPTION
The upscli_list_start() function takes the pointer ups to a UPSCONN_t state structure, and the pointer query to an array of numq query elements. It builds a properly-formatted request from those elements and transmits it to upsd(8). Upon success, the caller must call upscli_list_next(3) to retrieve the elements of the list. Failure to retrieve the list will most likely result in the client getting out of sync with the server due to buffered data. USES
This function implements the "LIST" command in the protocol. As a result, you can use it to request many different things from the server. Some examples are: o LIST UPS o LIST VAR <ups> o LIST RW <ups> o LIST CMD <ups> o LIST ENUM <ups> <var> o LIST RANGE <ups> <var> QUERY FORMATTING
To see the list of variables on a UPS called su700, the protocol command would be LIST VAR su700. To start that list with this function, you would populate query and numq as follows: int numq; const char *query[2]; query[0] = "VAR"; query[1] = "su700"; numq = 2; All escaping of special characters and quoting of elements with spaces are handled for you inside this function. ERROR CHECKING
This function checks the response from upsd(8) against your query. If it is not starting a list, or is starting the wrong type of list, it will return an error code. When this happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL. RETURN VALUE
The upscli_list_start() function returns 0 on success, or -1 if an error occurs. SEE ALSO
upscli_fd(3), upscli_get(3), upscli_readline(3), upscli_sendline(3), upscli_ssl(3), upscli_strerror(3), upscli_upserror(3) Network UPS Tools 05/31/2012 UPSCLI_LIST_START(3)
Man Page