2937
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 2000, 2005, 2006, 2007 John W. Eaton |
2937
|
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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2937
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2937
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_group_h) |
|
24 #define octave_group_h 1 |
|
25 |
|
26 #include <string> |
|
27 |
|
28 #ifdef HAVE_SYS_TYPES_H |
|
29 #include <sys/types.h> |
|
30 #endif |
|
31 |
|
32 #include "str-vec.h" |
|
33 |
|
34 class |
6108
|
35 OCTAVE_API |
2937
|
36 octave_group |
|
37 { |
|
38 public: |
|
39 |
|
40 octave_group (void) |
|
41 : gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false) |
|
42 { } |
|
43 |
|
44 octave_group (const octave_group& gr) |
|
45 : gr_name (gr.gr_name), gr_passwd (gr.gr_passwd), |
|
46 gr_gid (gr.gr_gid), gr_mem (gr.gr_mem), valid (gr.valid) |
|
47 { } |
|
48 |
|
49 octave_group& operator = (const octave_group& gr) |
|
50 { |
|
51 if (this != &gr) |
|
52 { |
|
53 gr_name = gr.gr_name; |
|
54 gr_passwd = gr.gr_passwd; |
|
55 gr_gid = gr.gr_gid; |
|
56 gr_mem = gr.gr_mem; |
|
57 valid = gr.valid; |
|
58 } |
|
59 |
|
60 return *this; |
|
61 } |
|
62 |
3504
|
63 std::string name (void) const; |
2937
|
64 |
3504
|
65 std::string passwd (void) const; |
2937
|
66 |
|
67 gid_t gid (void) const; |
|
68 |
|
69 string_vector mem (void) const; |
|
70 |
|
71 bool ok (void) const { return valid; } |
|
72 |
3145
|
73 operator bool () const { return ok (); } |
2937
|
74 |
|
75 static octave_group getgrent (void); |
3504
|
76 static octave_group getgrent (std::string& msg); |
2937
|
77 |
|
78 static octave_group getgrgid (gid_t gid); |
3504
|
79 static octave_group getgrgid (gid_t gid, std::string& msg); |
2937
|
80 |
3504
|
81 static octave_group getgrnam (const std::string& nm); |
|
82 static octave_group getgrnam (const std::string& nm, std::string& msg); |
2937
|
83 |
|
84 static int setgrent (void); |
3504
|
85 static int setgrent (std::string& msg); |
2937
|
86 |
|
87 static int endgrent (void); |
3504
|
88 static int endgrent (std::string& msg); |
2937
|
89 |
|
90 private: |
|
91 |
|
92 // The group name. |
3504
|
93 std::string gr_name; |
2937
|
94 |
|
95 // The group password. |
3504
|
96 std::string gr_passwd; |
2937
|
97 |
|
98 // The numeric group id. |
|
99 gid_t gr_gid; |
|
100 |
|
101 // The members of the group; |
|
102 string_vector gr_mem; |
|
103 |
|
104 // Flag that says whether we have been properly initialized. |
|
105 bool valid; |
|
106 |
|
107 // This is how we will create an octave_group object from a pointer |
|
108 // to a struct group. |
3504
|
109 octave_group (void *p, std::string& msg); |
2937
|
110 |
|
111 void gripe_invalid (void) const; |
|
112 }; |
|
113 |
|
114 #endif |
|
115 |
|
116 /* |
|
117 ;;; Local Variables: *** |
|
118 ;;; mode: C++ *** |
|
119 ;;; End: *** |
|
120 */ |