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 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 /** @file lib/queue-rights.c
21 * @brief Various rights-checking operations
32 /** @brief Test for scratchability
33 * @param rights User rights
35 * @param q Queue entry or NULL
36 * @return non-0 if scratchable, else 0
38 int right_scratchable(rights_type rights, const char *who,
39 const struct queue_entry *q) {
45 if(!strcmp(q->submitter, who))
46 r = RIGHT_SCRATCH_MINE|RIGHT_SCRATCH_ANY;
48 r = RIGHT_SCRATCH_ANY;
50 r = RIGHT_SCRATCH_RANDOM|RIGHT_SCRATCH_ANY;
51 return !!(rights & r);
54 /** @brief Test for movability
55 * @param rights User rights
57 * @param q Queue entry or NULL
58 * @return non-0 if movable, else 0
60 int right_movable(rights_type rights, const char *who,
61 const struct queue_entry *q) {
67 if(!strcmp(q->submitter, who))
68 r = RIGHT_MOVE_MINE|RIGHT_MOVE_ANY;
72 r = RIGHT_MOVE_RANDOM|RIGHT_MOVE_ANY;
73 return !!(rights & r);
76 /** @brief Test for removability
77 * @param rights User rights
79 * @param q Queue entry or NULL
80 * @return non-0 if removable, else 0
82 int right_removable(rights_type rights, const char *who,
83 const struct queue_entry *q) {
89 if(!strcmp(q->submitter, who))
90 r = RIGHT_REMOVE_MINE|RIGHT_REMOVE_ANY;
94 r = RIGHT_REMOVE_RANDOM|RIGHT_REMOVE_ANY;
95 return !!(rights & r);