GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-group.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_oct_group_h)
27 #define octave_oct_group_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 #include <sys/types.h>
34 
35 #include "str-vec.h"
36 
38 
40 
41 class
43 group
44 {
45 public:
46 
47  group ()
48  : m_name (), m_passwd (), m_gid (0), m_mem (), m_valid (false)
49  { }
50 
51  OCTAVE_DEFAULT_COPY_MOVE_DELETE (group)
52 
53  std::string name () const;
54 
55  std::string passwd () const;
56 
57  gid_t gid () const;
58 
59  string_vector mem () const;
60 
61  bool ok () const { return m_valid; }
62 
63  operator bool () const { return ok (); }
64 
65  static group getgrent ();
66  static group getgrent (std::string& msg);
67 
68  static group getgrgid (gid_t gid);
69  static group getgrgid (gid_t gid, std::string& msg);
70 
71  static group getgrnam (const std::string& nm);
72  static group getgrnam (const std::string& nm, std::string& msg);
73 
74  static int setgrent ();
75  static int setgrent (std::string& msg);
76 
77  static int endgrent ();
78  static int endgrent (std::string& msg);
79 
80 private:
81 
82  // The group name.
83  std::string m_name;
84 
85  // The group password.
86  std::string m_passwd;
87 
88  // The numeric group id.
89  gid_t m_gid;
90 
91  // The members of the group;
92  string_vector m_mem;
93 
94  // Flag that says whether we have been properly initialized.
95  bool m_valid;
96 
97  // This is how we will create an group object from a pointer
98  // to a struct group.
99  group (void *p, std::string& msg);
100 };
101 
102 OCTAVE_END_NAMESPACE(sys)
103 OCTAVE_END_NAMESPACE(octave)
104 
105 #endif
bool ok() const
Definition: oct-group.h:61
group()
Definition: oct-group.h:47
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition: main.cc:55