2 * This file is part of DisOrder.
3 * Copyright (C) 2007 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file lib/queue-rights.c
19 * @brief Various rights-checking operations
27 /** @brief Test for scratchability
28 * @param rights User rights
30 * @param q Queue entry or NULL
31 * @return non-0 if scratchable, else 0
33 int right_scratchable(rights_type rights, const char *who,
34 const struct queue_entry *q) {
40 if(!strcmp(q->submitter, who))
41 r = RIGHT_SCRATCH_MINE|RIGHT_SCRATCH_ANY;
43 r = RIGHT_SCRATCH_ANY;
45 r = RIGHT_SCRATCH_RANDOM|RIGHT_SCRATCH_ANY;
46 return !!(rights & r);
49 /** @brief Test for movability
50 * @param rights User rights
52 * @param q Queue entry or NULL
53 * @return non-0 if movable, else 0
55 int right_movable(rights_type rights, const char *who,
56 const struct queue_entry *q) {
62 if(!strcmp(q->submitter, who))
63 r = RIGHT_MOVE_MINE|RIGHT_MOVE_ANY;
67 r = RIGHT_MOVE_RANDOM|RIGHT_MOVE_ANY;
68 return !!(rights & r);
71 /** @brief Test for removability
72 * @param rights User rights
74 * @param q Queue entry or NULL
75 * @return non-0 if removable, else 0
77 int right_removable(rights_type rights, const char *who,
78 const struct queue_entry *q) {
84 if(!strcmp(q->submitter, who))
85 r = RIGHT_REMOVE_MINE|RIGHT_REMOVE_ANY;
89 r = RIGHT_REMOVE_RANDOM|RIGHT_REMOVE_ANY;
90 return !!(rights & r);