1UPSCLI_LIST_START(3)              NUT Manual              UPSCLI_LIST_START(3)
2
3
4

NAME

6       upscli_list_start - begin multi-item retrieval from a UPS
7

SYNOPSIS

9       #include <upsclient.h>
10
11       int upscli_list_start(UPSCONN_t *ups, size_t numq, const char **query)
12

DESCRIPTION

14       The upscli_list_start() function takes the pointer ups to a UPSCONN_t
15       state structure, and the pointer query to an array of numq query
16       elements. It builds a properly-formatted request from those elements
17       and transmits it to upsd(8).
18
19       Upon success, the caller must call upscli_list_next(3) to retrieve the
20       elements of the list. Failure to retrieve the list will most likely
21       result in the client getting out of sync with the server due to
22       buffered data.
23

USES

25       This function implements the "LIST" command in the protocol. As a
26       result, you can use it to request many different things from the
27       server. Some examples are:
28
29       •   LIST UPS
30
31       •   LIST VAR <ups>
32
33       •   LIST RW <ups>
34
35       •   LIST CMD <ups>
36
37       •   LIST ENUM <ups> <var>
38
39       •   LIST RANGE <ups> <var>
40

QUERY FORMATTING

42       To see the list of variables on a UPS called su700, the protocol
43       command would be LIST VAR su700. To start that list with this function,
44       you would populate query and numq as follows:
45
46                   size_t numq;
47                   const char *query[2];
48
49                   query[0] = "VAR";
50                   query[1] = "su700";
51                   numq = 2;
52
53       All escaping of special characters and quoting of elements with spaces
54       are handled for you inside this function.
55

ERROR CHECKING

57       This function checks the response from upsd(8) against your query. If
58       it is not starting a list, or is starting the wrong type of list, it
59       will return an error code.
60
61       When this happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL.
62

RETURN VALUE

64       The upscli_list_start() function returns 0 on success, or -1 if an
65       error occurs.
66

SEE ALSO

68       upscli_fd(3), upscli_get(3), upscli_readline(3), upscli_sendline(3),
69       upscli_ssl(3), upscli_strerror(3), upscli_upserror(3)
70
71
72
73Network UPS Tools 2.8.0           04/26/2022              UPSCLI_LIST_START(3)
Impressum