diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-01-03 13:58:15 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-01-03 13:58:15 +0100 |
commit | 4aca87515a5083ae0e31ce3177189fd43b6d05ac (patch) | |
tree | 7b1d9a31393ca090757dc6f0d3859b4fcd93f271 /release/src/router/busybox/libbb/print_flags.c | |
parent | 008d0be72b2f160382c6e880765e96b64a050c65 (diff) | |
download | tomato-4aca87515a5083ae0e31ce3177189fd43b6d05ac.tar.gz tomato-4aca87515a5083ae0e31ce3177189fd43b6d05ac.tar.bz2 |
patch to Vanilla Tomato 1.28
Diffstat (limited to 'release/src/router/busybox/libbb/print_flags.c')
-rw-r--r-- | release/src/router/busybox/libbb/print_flags.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/release/src/router/busybox/libbb/print_flags.c b/release/src/router/busybox/libbb/print_flags.c new file mode 100644 index 00000000..afa75503 --- /dev/null +++ b/release/src/router/busybox/libbb/print_flags.c @@ -0,0 +1,32 @@ +/* vi: set sw=4 ts=4: */ +/* Print string that matches bit masked flags + * + * Copyright (C) 2008 Natanael Copa <natanael.copa@gmail.com> + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ + +#include <libbb.h> + +/* returns a set with the flags not printed */ +int FAST_FUNC print_flags_separated(const int *masks, const char *labels, int flags, const char *separator) +{ + const char *need_separator = NULL; + while (*labels) { + if (flags & *masks) { + printf("%s%s", + need_separator ? need_separator : "", + labels); + need_separator = separator; + flags &= ~ *masks; + } + masks++; + labels += strlen(labels) + 1; + } + return flags; +} + +int FAST_FUNC print_flags(const masks_labels_t *ml, int flags) +{ + return print_flags_separated(ml->masks, ml->labels, flags, NULL); +} |