STRTOFFLAGS(3)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

✨ STRTOFFLAGS(3) ✨

okay so bestie, this is the STRTOFFLAGS(3) page from the Library Functions Manual β€” yes, section 3, the library-calls one πŸ’… we're converting file flag bits back and forth with their string names and it's honestly iconic.

πŸŽ€ NAME πŸŽ€

fflagstostr, strtofflags β€” the little duo that converts between file flag bits and their string names πŸ¦‹

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” the classic, the blueprint, no cap πŸ’–

🌸 SYNOPSIS 🌸

#include <unistd.h>

char *
fflagstostr(u_long flags);

int
strtofflags(char **stringp, u_long *setp, u_long *clrp);

like, just look at them. so clean. so main character 🫢

πŸ’« DESCRIPTION πŸ’«

okay so first up, fflagstostr() β€” she takes flags and returns a comma separated string of the file flags represented by flags. literally just vibes β†’ text. and if no flags are set? you get a zero length string back. not NULL, not a sad little error, just an empty string. she said "nothing to report bestie" πŸ’€

but ngl, if memory cannot be allocated for the return value, fflagstostr() returns NULL. that's the one bad ending πŸ™ˆ

here's the tea though β€” the value returned from fflagstostr() is obtained from malloc() and should be returned to the system with free() when the program is done with it. so like, please actually free it. don't leave it hanging. that's her main character arc πŸŽ€

then we have strtofflags() β€” the other direction. she takes stringp, a string of file flags as described in chflags(1), parses it, and hands you back the 'set' flags and 'clear' flags such as would be given as arguments to chflags(2). she's basically a translator for flag-speak 🧚

on success strtofflags() returns 0 ✨ otherwise it returns non-zero and stringp is left pointing to the offending token. so she snitches on exactly which token she's mad at. honestly? respectful. πŸ”₯

πŸ’€ ERRORS πŸ’€

fflagstostr() may fail and set errno for any of the errors specified for the library routine malloc(3).

so when things go wrong, it's a malloc(3) situation. check errno, bestie, it's literally telling you what happened 😭

πŸ” SEE ALSO πŸ”

like the whole friend group. go say hi 🫢

πŸ‘‘ HISTORY πŸ‘‘

the fflagstostr() and strtofflags() functions first appeared in FreeBSD 4.0. vintage! retro! ate! πŸ“


and that's the whole page, bestie πŸ’– this cutie came to you from Debian, dated January 1, 2000 β€” yes, the Y2K of it all, and she survived. slay πŸŽ€βœ¨

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms