2011-01-26 09:35:08 +00:00
'\" t
. \" Title: upscli_readline
2022-06-29 10:37:36 +00:00
. \" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
. \" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
. \" Date: 04/26/2022
2011-01-26 09:35:08 +00:00
. \" Manual: NUT Manual
2022-06-29 10:37:36 +00:00
. \" Source: Network UPS Tools 2.8.0
2011-01-26 09:35:08 +00:00
. \" Language: English
. \"
2022-06-29 10:37:36 +00:00
.TH "UPSCLI_READLINE" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual"
2011-01-26 09:35:08 +00:00
. \" -----------------------------------------------------------------
. \" * Define some portability stuff
. \" -----------------------------------------------------------------
. \" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. \" http://bugs.debian.org/507673
. \" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
. \" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n (.g .ds Aq \(aq
.el .ds Aq '
. \" -----------------------------------------------------------------
. \" * set default formatting
. \" -----------------------------------------------------------------
. \" disable hyphenation
.nh
. \" disable justification (adjust text to left margin only)
.ad l
. \" -----------------------------------------------------------------
. \" * MAIN CONTENT STARTS HERE *
. \" -----------------------------------------------------------------
.SH "NAME"
2022-06-29 10:37:36 +00:00
upscli_readline, upscli_readline_timeout \- read a single response from a UPS
2011-01-26 09:35:08 +00:00
.SH "SYNOPSIS"
.sp
.nf
#include <upsclient\& .h>
2022-06-29 10:37:36 +00:00
#include <time\& .h> /* or <sys/time\& .h> on some platforms */
2011-01-26 09:35:08 +00:00
.fi
.sp
.nf
int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen);
.fi
2022-06-29 10:37:36 +00:00
.sp
.nf
int upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen,
const time_t timeout);
.fi
2011-01-26 09:35:08 +00:00
.SH "DESCRIPTION"
.sp
2022-06-29 10:37:36 +00:00
The \fB upscli_readline()\fR and \fB upscli_readline_timeout()\fR functions take the pointer \fI ups\fR to a UPSCONN_t state structure, receive a single line from the server, and copy up to \fI buflen\fR bytes of the response into the buffer \fI buf\fR \& .
2011-01-26 09:35:08 +00:00
.sp
Some parsing of the string occurs during reception\& . In particular, ERR messages from \fB upsd\fR (8) are detected and will cause this function to return \- 1\& .
2022-06-29 10:37:36 +00:00
.sp
The difference between the two functions is that \fB upscli_readline_timeout()\fR lets the caller decide the amount of time (\fI timeout\fR seconds) after which it should give up and return, whereas \fB upscli_readline()\fR does not offer this freedom, and uses NUT default network timeout (5 seconds)\& .
2011-01-26 09:35:08 +00:00
.SH "RETURN VALUE"
.sp
2022-06-29 10:37:36 +00:00
The \fB upscli_readline()\fR and \fB upscli_readline_timeout()\fR functions return 0 on success, or \- 1 if an error occurs\& .
2011-01-26 09:35:08 +00:00
.SH "SEE ALSO"
.sp
\fB upscli_fd\fR (3), \fB upscli_get\fR (3), \fB upscli_readline\fR (3), \fB upscli_sendline\fR (3), \fB upscli_ssl\fR (3), \fB upscli_strerror\fR (3), \fB upscli_upserror\fR (3)