STRTOFFLAGS(3)
β¨ 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 amalloc(3)situation. checkerrno, 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
- Copyright (c) 1989, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms