Mercurial > octave
annotate liboctave/system/oct-group.h @ 28223:45763d59cb4f stable
use nullptr instead of NULL or 0 in a few more places
* QWinTerminalImpl.cpp, oct-procbuf.cc, audioread.cc, jit-typeinfo.cc,
lo-sysdep.cc, url-transfer.cc, shared-fcns.h: Replace NULL and 0 with
nullptr where appropriate.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 15 Apr 2020 15:55:32 -0400 |
parents | bd51beb6205e |
children | 0a5b15007766 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1996-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2937 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 #if ! defined (octave_oct_group_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
27 #define octave_oct_group_h 1 |
2937 | 28 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21102
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21102
diff
changeset
|
30 |
2937 | 31 #include <string> |
32 | |
33 #include <sys/types.h> | |
34 | |
35 #include "str-vec.h" | |
36 | |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21728
diff
changeset
|
37 namespace octave |
2937 | 38 { |
21734
11af9c03400c
write namespace keyword and name on same line in C++ files
John W. Eaton <jwe@octave.org>
parents:
21728
diff
changeset
|
39 namespace sys |
2937 | 40 { |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
41 class |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
42 OCTAVE_API |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
43 group |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
44 { |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
45 public: |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
46 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
47 group (void) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
48 : m_name (), m_passwd (), m_gid (0), m_mem (), valid (false) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
49 { } |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
50 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
51 group (const group& gr) |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
52 : m_name (gr.m_name), m_passwd (gr.m_passwd), |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
53 m_gid (gr.m_gid), m_mem (gr.m_mem), valid (gr.valid) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
54 { } |
2937 | 55 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
56 group& operator = (const group& gr) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
57 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
58 if (this != &gr) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
59 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
60 m_name = gr.m_name; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
61 m_passwd = gr.m_passwd; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
62 m_gid = gr.m_gid; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
63 m_mem = gr.m_mem; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
64 valid = gr.valid; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
65 } |
2937 | 66 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
67 return *this; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
68 } |
2937 | 69 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
70 std::string name (void) const; |
2937 | 71 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
72 std::string passwd (void) const; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
73 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
74 gid_t gid (void) const; |
2937 | 75 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
76 string_vector mem (void) const; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
77 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
78 bool ok (void) const { return valid; } |
2937 | 79 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
80 operator bool () const { return ok (); } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
81 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
82 static group getgrent (void); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
83 static group getgrent (std::string& msg); |
2937 | 84 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
85 static group getgrgid (gid_t gid); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
86 static group getgrgid (gid_t gid, std::string& msg); |
2937 | 87 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
88 static group getgrnam (const std::string& nm); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
89 static group getgrnam (const std::string& nm, std::string& msg); |
2937 | 90 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
91 static int setgrent (void); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
92 static int setgrent (std::string& msg); |
2937 | 93 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
94 static int endgrent (void); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
95 static int endgrent (std::string& msg); |
2937 | 96 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
97 private: |
2937 | 98 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
99 // The group name. |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
100 std::string m_name; |
2937 | 101 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
102 // The group password. |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
103 std::string m_passwd; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
104 |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
105 // The numeric group id. |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
106 gid_t m_gid; |
2937 | 107 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
108 // The members of the group; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
109 string_vector m_mem; |
2937 | 110 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
111 // Flag that says whether we have been properly initialized. |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
112 bool valid; |
2937 | 113 |
21728
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
114 // This is how we will create an group object from a pointer |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
115 // to a struct group. |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
116 group (void *p, std::string& msg); |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
117 }; |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
118 } |
c218a5b31ad7
use namespace for system group wrapper class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
119 } |
2937 | 120 |
121 #endif |