2937
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2937
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_group_h) |
|
25 #define octave_group_h 1 |
|
26 |
|
27 #include <string> |
|
28 |
|
29 #ifdef HAVE_SYS_TYPES_H |
|
30 #include <sys/types.h> |
|
31 #endif |
|
32 |
|
33 #include "str-vec.h" |
|
34 |
|
35 class |
6108
|
36 OCTAVE_API |
2937
|
37 octave_group |
|
38 { |
|
39 public: |
|
40 |
|
41 octave_group (void) |
|
42 : gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false) |
|
43 { } |
|
44 |
|
45 octave_group (const octave_group& gr) |
|
46 : gr_name (gr.gr_name), gr_passwd (gr.gr_passwd), |
|
47 gr_gid (gr.gr_gid), gr_mem (gr.gr_mem), valid (gr.valid) |
|
48 { } |
|
49 |
|
50 octave_group& operator = (const octave_group& gr) |
|
51 { |
|
52 if (this != &gr) |
|
53 { |
|
54 gr_name = gr.gr_name; |
|
55 gr_passwd = gr.gr_passwd; |
|
56 gr_gid = gr.gr_gid; |
|
57 gr_mem = gr.gr_mem; |
|
58 valid = gr.valid; |
|
59 } |
|
60 |
|
61 return *this; |
|
62 } |
|
63 |
3504
|
64 std::string name (void) const; |
2937
|
65 |
3504
|
66 std::string passwd (void) const; |
2937
|
67 |
|
68 gid_t gid (void) const; |
|
69 |
|
70 string_vector mem (void) const; |
|
71 |
|
72 bool ok (void) const { return valid; } |
|
73 |
3145
|
74 operator bool () const { return ok (); } |
2937
|
75 |
|
76 static octave_group getgrent (void); |
3504
|
77 static octave_group getgrent (std::string& msg); |
2937
|
78 |
|
79 static octave_group getgrgid (gid_t gid); |
3504
|
80 static octave_group getgrgid (gid_t gid, std::string& msg); |
2937
|
81 |
3504
|
82 static octave_group getgrnam (const std::string& nm); |
|
83 static octave_group getgrnam (const std::string& nm, std::string& msg); |
2937
|
84 |
|
85 static int setgrent (void); |
3504
|
86 static int setgrent (std::string& msg); |
2937
|
87 |
|
88 static int endgrent (void); |
3504
|
89 static int endgrent (std::string& msg); |
2937
|
90 |
|
91 private: |
|
92 |
|
93 // The group name. |
3504
|
94 std::string gr_name; |
2937
|
95 |
|
96 // The group password. |
3504
|
97 std::string gr_passwd; |
2937
|
98 |
|
99 // The numeric group id. |
|
100 gid_t gr_gid; |
|
101 |
|
102 // The members of the group; |
|
103 string_vector gr_mem; |
|
104 |
|
105 // Flag that says whether we have been properly initialized. |
|
106 bool valid; |
|
107 |
|
108 // This is how we will create an octave_group object from a pointer |
|
109 // to a struct group. |
3504
|
110 octave_group (void *p, std::string& msg); |
2937
|
111 |
|
112 void gripe_invalid (void) const; |
|
113 }; |
|
114 |
|
115 #endif |
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; End: *** |
|
121 */ |