*** empty log message ***
[coreutils.git] / lib / modechange.h
blob922f85ab432b3142894697084a2cf0ddf4f87e68
1 /* modechange.h -- definitions for file mode manipulation
2 Copyright (C) 1989, 1990, 1997 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /* Masks for the `flags' field in a `struct mode_change'. */
20 #if ! defined MODECHANGE_H_
21 # define MODECHANGE_H_
23 # if HAVE_CONFIG_H
24 # include <config.h>
25 # endif
27 # include <sys/types.h>
29 /* Affect the execute bits only if at least one execute bit is set already,
30 or if the file is a directory. */
31 # define MODE_X_IF_ANY_X 01
33 /* If set, copy some existing permissions for u, g, or o onto the other two.
34 Which of u, g, or o is copied is determined by which bits are set in the
35 `value' field. */
36 # define MODE_COPY_EXISTING 02
38 struct mode_change
40 char op; /* One of "=+-". */
41 char flags; /* Special operations. */
42 mode_t affected; /* Set for u/g/o/s/s/t, if to be affected. */
43 mode_t value; /* Bits to add/remove. */
44 struct mode_change *next; /* Link to next change in list. */
47 /* Masks for mode_compile argument. */
48 # define MODE_MASK_EQUALS 1
49 # define MODE_MASK_PLUS 2
50 # define MODE_MASK_MINUS 4
51 # define MODE_MASK_ALL (MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS)
53 /* Error return values for mode_compile. */
54 # define MODE_INVALID (struct mode_change *) 0
55 # define MODE_MEMORY_EXHAUSTED (struct mode_change *) 1
56 # define MODE_BAD_REFERENCE (struct mode_change *) 2
58 # ifndef PARAMS
59 # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
60 # define PARAMS(Args) Args
61 # else
62 # define PARAMS(Args) ()
63 # endif
64 # endif
66 struct mode_change *mode_compile PARAMS ((const char *, unsigned));
67 struct mode_change *mode_create_from_ref PARAMS ((const char *));
68 mode_t mode_adjust PARAMS ((mode_t, const struct mode_change *));
69 void mode_free PARAMS ((struct mode_change *));
71 #endif