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 |
|
62 string name (void) const; |
|
63 |
|
64 string passwd (void) const; |
|
65 |
|
66 gid_t gid (void) const; |
|
67 |
|
68 string_vector mem (void) const; |
|
69 |
|
70 bool ok (void) const { return valid; } |
|
71 |
|
72 operator void* () const |
|
73 { return ok () |
|
74 ? static_cast<void *> (-1) : static_cast<void *> (0); } |
|
75 |
|
76 static octave_group getgrent (void); |
|
77 static octave_group getgrent (string& msg); |
|
78 |
|
79 static octave_group getgrgid (gid_t gid); |
|
80 static octave_group getgrgid (gid_t gid, string& msg); |
|
81 |
|
82 static octave_group getgrnam (const string& nm); |
|
83 static octave_group getgrnam (const string& nm, string& msg); |
|
84 |
|
85 static int setgrent (void); |
|
86 static int setgrent (string& msg); |
|
87 |
|
88 static int endgrent (void); |
|
89 static int endgrent (string& msg); |
|
90 |
|
91 private: |
|
92 |
|
93 // The group name. |
|
94 string gr_name; |
|
95 |
|
96 // The group password. |
|
97 string gr_passwd; |
|
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. |
|
110 octave_group (void *p, string& msg); |
|
111 |
|
112 void gripe_invalid (void) const; |
|
113 }; |
|
114 |
|
115 #endif |
|
116 |
|
117 /* |
|
118 ;;; Local Variables: *** |
|
119 ;;; mode: C++ *** |
|
120 ;;; End: *** |
|
121 */ |