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 1 and sets values in numa and answer βœ…
  • if the list is finished β€” it returns 0, and ngl, the values in numa and answer are 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:

  • 1 when list data is present ✨
  • 0 if the list is finished πŸŽ€
  • -1 if 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