UPSCLI_SPLITNAME(3)
β¨ UPSCLI_SPLITNAME β¨
okay bestie, pull up a chair π this is upscli_splitname(3), straight outta the NUT Manual (that's Network UPS Tools, not the other kind of nut, i promise π). it's a lil C function that takes one messy UPS string and deconstructs it into its gorgeous little component parts. it's giving chemistry class but make it networking π§ͺβ¨
πΈ NAME πΈ
upscli_splitname β split a UPS definition into its components π
π SYNOPSIS π
#include <upsclient.h>
int upscli_splitname(const char *buf, char **upsname,
char **hostname, int *port)
like, look at her. four params. she's simple. she's iconic. she's not here to play π
π¦ DESCRIPTION π¦
so here's the tea β β upscli_splitname() takes a pointer to the raw UPS definition in buf, and hands you back pointers to dynamically allocated memory in upsname and hostname. it also copies the port number right into port. that's it. that's the whole job. no cap π«Ά
π FORMATTING π
an UPS definition gets written according to this format, and yes it's giving choose-your-own-adventure:
<upsname>[@<hostname>[:<port>]]
so like, brackets inside brackets. very nesting-coded. very russian-doll of her πͺ
now the important part: when the UPS name is not given, this function will print an error to stderr and return -1 without changing anything. no half-finished vibes, no partial glow-up. she just refuses π
definitions that don't have an explicit port value get the default value of 3493. and the default hostname is "localhost". the defaults ate, honestly π
π MEMORY USAGE π
you must free(3) the pointers to upsname and hostname when you're done with them, or you're gonna leak memory and that's not the vibe. clean up after yourself, bestie π§Ήβ¨
π₯ RETURN VALUE π₯
0β slayed, success, everything worked π-1β something went wrong, an error occurred π
π SEE ALSO π
upscli_fd(3)upscli_get(3)upscli_readline(3)upscli_sendline(3)upscli_splitaddr(3)upscli_ssl(3)upscli_strerror(3)upscli_upserror(3)
and that's the whole page, babe π«Ά this was Network UPS Tools 2.8.5, dated 10/07/2026, and honestly? she served. go forth and split some names πβ¨π
π¦ 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