radcli_avp_concat_str(3)
π
radcli_avp_concat_str β from the radcli manual, section 3
okay so bestie, buckle up, because this one is literally the "grab every copy of an attribute and smoosh them into one string" function, and it ATE. it's radcli_avp_concat_str(3) and it's about to make your reply-parsing life so much easier π«Ά
β¨ SYNOPSIS β¨
#include <radcli/>
int radcli_avp_concat_str(
char *buf,
size_t buflen,
const radcli_avp_list *list,
const radcli_attr_def *def,
const char *sep
);
πΈ DESCRIPTION πΈ
so basically this generalizes the one little convenience thing that legacy radcli.h's rc_aaa() used to fold right into its own call signature β you know, its msg parameter, the one that "will contain the concatenation of any PW_REPLY_MESSAGE received" (lib/buildreq.c) π« β except now it works for any attribute, not just Reply-Message. because the pattern "walk every occurrence of one attribute in a reply, join as text" was never actually specific to Reply-Message, and everyone knew it. so if you're a caller who just wants rc_aaa()'s old convenience? you no longer have to hand-roll the whole radcli_avp_get()-in-a-loop thing that this function replaces. no cap, that loop can retire π
if there's no occurrence of def present in list, buf gets set to an empty string and 0 is returned β and that is not a failure, okay? it's the exact same energy as rc_aaa()'s msg starting out as '' and just... staying that way when no Reply-Message ever showed up. iconic, honestly. and an attribute whose value contains an embedded NUL byte, or (for a RADCLI_TYPE_TEXT attribute) invalid UTF-8, gets skipped β that's radcli_avp_get_cstr()'s policy β and it's also not treated as a failure. no drama, just vibes π
it follows snprintf()'s buffer-sizing contract exactly, and when I say exactly I mean it:
bufmay beNULLand/orbuflenmay be0so you can size a buffer before you allocate one (in that case nothing gets written, periodt)- the return value is always the number of bytes the joined result would occupy, whether or not it actually fit
- so a return
>= buflenmeans the result was truncated, andbuf(if it's non-NULLandbuflen > 0) then holds only a valid NUL-terminated prefix of whatever fits β never garbage, never unterminated π
π PARAMETERS π
bufβ the destination buffer, orNULLif you only want to compute the needed size. it's always left NUL-terminated on return (truncation included, holding whatever fit) wheneverbufis non-NULLandbuflen > 0π¦buflenβ size ofbuf, in bytes. may be0.listβ the list you're searching. your scavenger hunt β¨defβ the attribute you want to concatenate occurrences of.sepβ the separator inserted between occurrences.NULLor""for none. (yes, both work, live your truth)
π RETURN VALUE π
the number of bytes the joined result occupies (excluding the NUL terminator), whether or not it fit in buf β or -1 if def is NULL. that's it, that's the deal π₯
π SEE ALSO π
your reading list, bestie, and yes you're gonna read all of them:
radcli_avp_add_bytes(3)radcli_avp_add_bytes_by_num(3)radcli_avp_add_gigawords64(3)radcli_avp_add_gigawords64_by_num(3)radcli_avp_add_ip4(3)radcli_avp_add_ip4_by_num(3)radcli_avp_add_ip4prefix(3)radcli_avp_add_ip4prefix_by_num(3)radcli_avp_add_ip6(3)radcli_avp_add_ip6_by_num(3)radcli_avp_add_str(3)radcli_avp_add_str_by_num(3)radcli_avp_add_uint32(3)radcli_avp_add_uint32_by_num(3)radcli_avp_add_uint64(3)radcli_avp_add_uint64_by_num(3)radcli_avp_add_username(3)radcli_avp_concat_str_by_num(3)radcli_avp_def(3)radcli_avp_get(3)radcli_avp_get_by_num(3)radcli_avp_get_bytes(3)radcli_avp_get_bytes_by_num(3)radcli_avp_get_cstr(3)radcli_avp_get_cstr_by_num(3)radcli_avp_get_gigawords64(3)radcli_avp_get_gigawords64_by_num(3)radcli_avp_get_ip4prefix(3)radcli_avp_get_ip4prefix_by_num(3)radcli_avp_get_ip6(3)radcli_avp_get_ip6_by_num(3)radcli_avp_get_uint32(3)radcli_avp_get_uint32_by_num(3)radcli_avp_get_uint64(3)radcli_avp_get_uint64_by_num(3)radcli_avp_iter_next(3)radcli_avp_list_error(3)radcli_avp_list_free(3)radcli_avp_list_iter(3)radcli_avp_list_new(3)
friendly reminder from your local Unix bestie:bufmay beNULLandbuflenmay be0β that's the size-only mode, nothing is written, don't panic π
okay that's the whole page, mwah π this came out of the radcli source, dated 2026-10-10, and the page itself is radcli_avp_concat_str(3) β go forth and concatenate, you absolute main character π
π¦ where this page comes from
- arch rolling: radcli 2.0.1-1 Β· BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms