atexpand(3)
π atexpand(3) β bestie edition π
AtFS Toolkit Library Β· section 3, the library calls, we love her π
β¨ NAME β¨
atExpandAttrs, atExpand β attribute expansion, aka the glow-up machine for your strings πΈ
π¦ SYNOPSIS π¦
#include <atfs.h>
#include <atfstk.h>
int atExpandAttrs (Af_key *aso, char *buf, size_t bufSize, FILE *dest,
size_t destSize, int mode);
int atExpand;
yeah that second one is just a variable, no parentheses, she's living her best life π«Ά
π DESCRIPTION π
okay so, atExpandAttrs goes on a lil scavenger hunt through the char buffer buf, and it looks all the way up to bufSize for strings shaped like $__attributeName β and sometimes that lil guy is followed by a delimiting second dollar sign ($), cute, optional, iconic.
When it finds one of those? Everything in the buffer up to the character right before that first dollar sign gets sent straight to the destination output dest. β¨
Then, if an attribute named attributeName is actually set for the current attributed software object aso, that citation-string gets swapped out for the value of that attribute and appended to the output. slay. π
And then β this is the part people miss β output of the buf contents picks back up at the first character after the whitespace character or dollar sign that delimited attributeName. no cap.
π the string-buffer plot twist π
ngl, the type of the dest argument is "pointer to file structure," but bestie, you can still make atExpandAttrs copy its output into a string buffer instead of an open file. here's the tea π:
- you must pass the constant
AT_EXPAND_STRINGas themodeargument - and
bufSizemust be set to indicate the length of the destination bufferdest(it gets casted to character pointer, don't worry abt it)
π¨ ifdestSizeis too small to hold the result string,atExpandAttrsreturns a negative value. beware, she will not be silenced, she will simply say no.
in the regular case β the one where output shall be written to a file β the mode parameter must be AT_EXPAND_FILE. periodt. π₯
π§ the atExpand variable π§
the atExpand variable suppresses attribute expansion when set FALSE. (that's the whole personality.)
you can set it:
- directly from the application program, or
- indirectly by evaluation of the pseudo attribute citation
$__xpoffin any buffer scanned byatExpandAttrs
and then there's her sister $__xpon, another pseudo attribute citation β she cancels the effect of a previous $__xpoff and switches attribute citation back on again. π
β οΈ but lowkey important: $__xpon does not enable attribute citation if it was disabled explicitly by the application program. she can undo her own drama, not yours. π
π DIAGNOSTICS π
atExpandAttrs returns -1 on error. and bestie, it doesn't just ghost you β additionally, the atError variable is set, and afErrMsg holds a diagnostic message. the group chat has receipts. π
π SEE ALSO π
that's the whole page, you're so welcome, go expand some attributes, you absolute main character πβ¨
mwah π β written up by the AtFS Toolkit Library, version AtFStk-1.12, dated Fri Jun 25 16:39:36 1993 (an elder, but a legend fr fr π)
π¦ where this page comes from
- debian bookworm: atfs-dev 1.4pl6-15+b1
- ubuntu jammy: atfs-dev 1.4pl6-15
- ubuntu noble: atfs-dev 1.4pl6-16.1build1
- ubuntu resolute: atfs-dev 1.4pl6-17
- ubuntu stonking: atfs-dev 1.4pl6-17
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms