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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
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 |
|
35 octave_group |
|
36 { |
|
37 public: |
|
38 |
|
39 octave_group (void) |
|
40 : gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false) |
|
41 { } |
|
42 |
|
43 octave_group (const octave_group& gr) |
|
44 : gr_name (gr.gr_name), gr_passwd (gr.gr_passwd), |
|
45 gr_gid (gr.gr_gid), gr_mem (gr.gr_mem), valid (gr.valid) |
|
46 { } |
|
47 |
|
48 octave_group& operator = (const octave_group& gr) |
|
49 { |
|
50 if (this != &gr) |
|
51 { |
|
52 gr_name = gr.gr_name; |
|
53 gr_passwd = gr.gr_passwd; |
|
54 gr_gid = gr.gr_gid; |
|
55 gr_mem = gr.gr_mem; |
|
56 valid = gr.valid; |
|
57 } |
|
58 |
|
59 return *this; |
|
60 } |
|
61 |
3504
|
62 std::string name (void) const; |
2937
|
63 |
3504
|
64 std::string passwd (void) const; |
2937
|
65 |
|
66 gid_t gid (void) const; |
|
67 |
|
68 string_vector mem (void) const; |
|
69 |
|
70 bool ok (void) const { return valid; } |
|
71 |
3145
|
72 operator bool () const { return ok (); } |
2937
|
73 |
|
74 static octave_group getgrent (void); |
3504
|
75 static octave_group getgrent (std::string& msg); |
2937
|
76 |
|
77 static octave_group getgrgid (gid_t gid); |
3504
|
78 static octave_group getgrgid (gid_t gid, std::string& msg); |
2937
|
79 |
3504
|
80 static octave_group getgrnam (const std::string& nm); |
|
81 static octave_group getgrnam (const std::string& nm, std::string& msg); |
2937
|
82 |
|
83 static int setgrent (void); |
3504
|
84 static int setgrent (std::string& msg); |
2937
|
85 |
|
86 static int endgrent (void); |
3504
|
87 static int endgrent (std::string& msg); |
2937
|
88 |
|
89 private: |
|
90 |
|
91 // The group name. |
3504
|
92 std::string gr_name; |
2937
|
93 |
|
94 // The group password. |
3504
|
95 std::string gr_passwd; |
2937
|
96 |
|
97 // The numeric group id. |
|
98 gid_t gr_gid; |
|
99 |
|
100 // The members of the group; |
|
101 string_vector gr_mem; |
|
102 |
|
103 // Flag that says whether we have been properly initialized. |
|
104 bool valid; |
|
105 |
|
106 // This is how we will create an octave_group object from a pointer |
|
107 // to a struct group. |
3504
|
108 octave_group (void *p, std::string& msg); |
2937
|
109 |
|
110 void gripe_invalid (void) const; |
|
111 }; |
|
112 |
|
113 #endif |
|
114 |
|
115 /* |
|
116 ;;; Local Variables: *** |
|
117 ;;; mode: C++ *** |
|
118 ;;; End: *** |
|
119 */ |