* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)stat_flags.c 8.1 (Berkeley) %G%";
(void)strcat(string, prefix); \
(void)strcat(string, s); \
* Convert stat flags to a comma-separated string. If no flags
* are set, return the default string.
flags_to_string(flags
, def
)
if (flags
& UF_IMMUTABLE
)
if (flags
& SF_IMMUTABLE
)
return (prefix
== NULL
&& def
!= NULL
? def
: string
);
#define TEST(a, b, f) { \
if (!memcmp(a, b, sizeof(b))) { \
* Take string of arguments and return stat flags. Return 0 on
* success, 1 on failure. On failure, stringp is set to point
* to the offending token.
string_to_flags(stringp
, setp
, clrp
)
while ((p
= strsep(&string
, "\t ,")) != NULL
) {
if (p
[0] == 'n' && p
[1] == 'o') {
TEST(p
, "arch", SF_ARCHIVED
);
TEST(p
, "archived", SF_ARCHIVED
);
TEST(p
, "dump", UF_NODUMP
);
TEST(p
, "sappnd", SF_APPEND
);
TEST(p
, "sappend", SF_APPEND
);
TEST(p
, "schg", SF_IMMUTABLE
);
TEST(p
, "schange", SF_IMMUTABLE
);
TEST(p
, "simmutable", SF_IMMUTABLE
);
TEST(p
, "uappnd", UF_APPEND
);
TEST(p
, "uappend", UF_APPEND
);
TEST(p
, "uchg", UF_IMMUTABLE
);
TEST(p
, "uchange", UF_IMMUTABLE
);
TEST(p
, "uimmutable", UF_IMMUTABLE
);