1UPSCLI_READLINE(3) NUT Manual UPSCLI_READLINE(3)
2
3
4
6 upscli_readline, upscli_readline_timeout - read a single response from
7 a UPS
8
10 #include <upsclient.h>
11 #include <time.h> /* or <sys/time.h> on some platforms */
12
13 int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen);
14
15 int upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen,
16 const time_t timeout);
17
19 The upscli_readline() and upscli_readline_timeout() functions take the
20 pointer ups to a UPSCONN_t state structure, receive a single line from
21 the server, and copy up to buflen bytes of the response into the buffer
22 buf.
23
24 Some parsing of the string occurs during reception. In particular, ERR
25 messages from upsd(8) are detected and will cause this function to
26 return -1.
27
28 The difference between the two functions is that
29 upscli_readline_timeout() lets the caller decide the amount of time
30 (timeout seconds) after which it should give up and return, whereas
31 upscli_readline() does not offer this freedom, and uses NUT default
32 network timeout (5 seconds).
33
35 The upscli_readline() and upscli_readline_timeout() functions return 0
36 on success, or -1 if an error occurs.
37
39 upscli_fd(3), upscli_get(3), upscli_readline(3), upscli_sendline(3),
40 upscli_ssl(3), upscli_strerror(3), upscli_upserror(3)
41
42
43
44Network UPS Tools 2.8.0 04/26/2022 UPSCLI_READLINE(3)