3b7defab |
1 | /* -*-c-*- |
2 | * |
7481fc9c |
3 | * $Id: fattr.h,v 1.2 2004/04/08 01:36:25 mdw Exp $ |
3b7defab |
4 | * |
5 | * Handling of file attributes |
6 | * |
7 | * (c) 1999 Straylight/Edgeware |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of the `fw' port forwarder. |
13 | * |
14 | * `fw' is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2 of the License, or |
17 | * (at your option) any later version. |
18 | * |
19 | * `fw' is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU General Public License for more details. |
23 | * |
24 | * You should have received a copy of the GNU General Public License |
25 | * along with `fw'; if not, write to the Free Software Foundation, |
26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
27 | */ |
28 | |
3b7defab |
29 | #ifndef FATTR_H |
30 | #define FATTR_H |
31 | |
32 | #ifdef __cplusplus |
33 | extern "C" { |
34 | #endif |
35 | |
36 | /*----- Header files ------------------------------------------------------*/ |
37 | |
38 | #include "config.h" |
39 | |
40 | #include <sys/types.h> |
41 | |
42 | #include "scan.h" |
43 | |
44 | /*----- Data structures ---------------------------------------------------*/ |
45 | |
46 | typedef struct fattr { |
47 | unsigned mode; |
48 | uid_t uid; |
49 | gid_t gid; |
50 | } fattr; |
51 | |
52 | /*----- Global variables --------------------------------------------------*/ |
53 | |
54 | extern fattr fattr_global; |
55 | |
56 | /*----- Functions provided ------------------------------------------------*/ |
57 | |
58 | /* --- @fattr_init@ --- * |
59 | * |
60 | * Arguments: @fattr *f@ = pointer to file attributes |
61 | * |
62 | * Returns: --- |
63 | * |
64 | * Use: Initializes a set of file attributes to default values. |
65 | */ |
66 | |
67 | extern void fattr_init(fattr */*f*/); |
68 | |
69 | /* --- @fattr_option@ --- * |
70 | * |
71 | * Arguments: @scanner *sc@ = pointer to scanner to read |
72 | * @fattr *f@ = pointer to file attributes to set |
73 | * |
74 | * Returns: Whether the option was clamed. |
75 | * |
76 | * Use: Reads file attributes from a scanner. |
77 | */ |
78 | |
79 | extern int fattr_option(scanner */*sc*/, fattr */*f*/); |
80 | |
81 | /* --- @fattr_apply@ --- * |
82 | * |
83 | * Arguments: @const char *file@ = pointer to filename |
84 | * @fattr *f@ = pointer to attribute set |
85 | * |
86 | * Returns: @-1@ if it failed. |
87 | * |
88 | * Use: Applies file attributes to a file. For best results, try to |
89 | * create the file with the right permissions and so on. This |
90 | * call will fix everything up, but there are potential races |
91 | * which might catch you out if you're not careful. |
92 | */ |
93 | |
94 | extern int fattr_apply(const char */*file*/, fattr */*f*/); |
95 | |
96 | /*----- That's all, folks -------------------------------------------------*/ |
97 | |
98 | #ifdef __cplusplus |
99 | } |
100 | #endif |
101 | |
102 | #endif |