diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-11-16 00:22:23 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-11-16 00:25:26 +0100 |
commit | ee0abeed2ca39cc0af67029c7b53d8c52ad52a79 (patch) | |
tree | 89daa16fa77639373f2dfa409187bc4af3876a18 /src/slibc-human | |
parent | m machinemode (diff) | |
download | slibc-ee0abeed2ca39cc0af67029c7b53d8c52ad52a79.tar.gz slibc-ee0abeed2ca39cc0af67029c7b53d8c52ad52a79.tar.bz2 slibc-ee0abeed2ca39cc0af67029c7b53d8c52ad52a79.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/slibc-human/machinemode.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/slibc-human/machinemode.c b/src/slibc-human/machinemode.c index 7efa2b5..dce7630 100644 --- a/src/slibc-human/machinemode.c +++ b/src/slibc-human/machinemode.c @@ -40,22 +40,23 @@ */ int machinemode(mode_t* restrict mode, mode_t* restrict mask, const char* restrict str) { -#define S_ISUSR (S_ISUID | S_IXUSR) -#define S_ISGRP (S_ISGID | S_IXGRO) -#define S_ISOTH (S_ISVTX | S_IXOTH) +#define S_ISUSR (S_ISUID | S_IXUSR) +#define S_ISGRP (S_ISGID | S_IXGRO) +#define S_ISOTH (S_ISVTX | S_IXOTH) -#define TEST_(S, T, V) (strstarts(str, S) && !(T & (v = V))) -#define TEST(S, T) (TEST_(S"+", T, 1) || TEST_(S"-", T, 2) || TEST_(S"=", T, 3)) -#define TESTV(T) (TEST(#T, T) ? (T = v) : 0) +#define TEST_(S, T, V) (strstarts(str, S) && !(T & (v = V))) +#define TEST(S, T) (TEST_(S"+", T, 1) || TEST_(S"-", T, 2) || TEST_(S"=", T, 3)) +#define TESTV(T) (TEST(#T, T) ? (T = v) : 0) -#define BITS(var) \ - if (*str == 'r') { if (var & bits[i][0]) goto invalid; else var |= bits[i][0]; } \ - else if (*str == 'w') { if (var & bits[i][1]) goto invalid; else var |= bits[i][1]; } \ - else if (*str == 'x') { if (var & bits[i][3]) goto invalid; else var |= bits[i][2]; } \ - else if (*str == 's') { if (var & bits[i][3]) goto invalid; else var |= bits[i][3]; } \ - else if (*str == 'S') { if (var & bits[i][3]) goto invalid; else var |= bits[i][4]; } \ - else if (*str == 't') { if (var & bits[i][3]) goto invalid; else var |= bits[i][3]; } \ - else if (*str == 'T') { if (var & bits[i][3]) goto invalid; else var |= bits[i][4]; } \ +#define BITS_(V, T, S) if (V & bits[i][T]) goto invalid; else var |= bits[i][S] +#define BITS(V) \ + if (*str == 'r') { BITS_(V, 0, 0); } \ + else if (*str == 'w') { BITS_(V, 1, 1); } \ + else if (*str == 'x') { BITS_(V, 3, 2); } \ + else if (*str == 's') { BITS_(V, 3, 3); } \ + else if (*str == 't') { BITS_(V, 3, 3); } \ + else if (*str == 'S') { BITS_(V, 3, 4); } \ + else if (*str == 'T') { BITS_(V, 3, 4); } \ else if (*str != '-') goto invalid int i, j, n, u = 0, g = 0, o = 0, v; |