UPSCLI_LIST_NEXT(3)
β¨ UPSCLI_LIST_NEXT β¨
okay bestie, so this is upscli_list_next(3) from the NUT Manual (Network UPS Tools), and it's literally the lil function that goes and grabs list items from a UPS π
πΈ NAME πΈ
upscli_list_next β Retrieve list items from a UPS π
π SYNOPSIS π
#include <upsclient.h>
int upscli_list_next(
UPSCONN_t *ups,
size_t numq,
const char **query,
size_t *numa,
char ***answer)
π DESCRIPTION π
so like. upscli_list_next() takes the pointer ups (which points at a UPSCONN_t state structure) and the pointer query (an array of numq query elements). Then it does a read from the network and is like "okay, is this another list item or are we done here?" π
π¨ real talk: you must call upscli_list_start(3) before you call this function. no skipping, no shortcuts, periodt.
Here's the vibe check on what it returns:
- if a list item comes back β it returns
1and sets values innumaandanswerβ - if the list is finished β it returns
0, and ngl, the values innumaandanswerare undefined at that point π
π and this one matters: calling this function after it returns something other than 1 is undefined behavior. not in a cute way. in a "why would you do that" way.
π¦ QUERY FORMATTING π¦
You may not change the values of numq or query between the call to upscli_list_start(3) and the first call to this function. π«Ά
And you also may not change the values between calls to this function. so like, set it and leave it alone bestie, it's giving "commitment issues are not the move here." β¨
β ANSWER FORMATTING β
The contents of numa and answer work just like a call to upscli_get(3). π
The values returned by upsd(8) are identical to a single item request β so honestly? not surprising at all. iconic consistency, we love to see it. π
π₯ ERROR CHECKING π₯
This function checks the response from upsd(8) against your query. If the response isn't part of the list you requested, it's gonna return an error code. π
When that happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL.
π RETURN VALUE π
upscli_list_next() returns:
1when list data is present β¨0if the list is finished π-1if an error occurs π
And psst β it is possible to have an empty list! In that case the function will return 0 on its very first call. no cap. π
π SEE ALSO π
okay that's the whole thing, you ate that reading session fr fr π
this lil masterpiece is from Network UPS Tools 2.8.5, dated 10/07/2026 β go off, NUT team π
π¦ where this page comes from
- fedora 43: nut-devel 2.8.5-9.fc43 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 43: nut-devel 2.8.5-9.fc43 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 44: nut-devel 2.8.5-9.fc44 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 44: nut-devel 2.8.5-9.fc44 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms