File: upscli_list_start.txt

package info (click to toggle)
nut 2.7.4-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,964 kB
  • sloc: ansic: 70,278; sh: 12,814; python: 2,202; cpp: 1,715; makefile: 1,406; perl: 705; xml: 40
file content (82 lines) | stat: -rw-r--r-- 2,061 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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, unsigned 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 linkman:upsd[8].

Upon success, the caller must call linkman: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:

 - LIST UPS
 - LIST VAR <ups>
 - LIST RW <ups>
 - LIST CMD <ups>
 - LIST ENUM <ups> <var>
 - 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:

	unsigned 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 linkman: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, linkman: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
--------

linkman:upscli_fd[3], linkman:upscli_get[3],
linkman:upscli_readline[3], linkman:upscli_sendline[3],
linkman:upscli_ssl[3],
linkman:upscli_strerror[3], linkman:upscli_upserror[3]