GNU Octave 7.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-2022 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
37namespace octave
38{
39 namespace sys
40 {
41 class
43 group
44 {
45 public:
46
47 group (void)
48 : m_name (), m_passwd (), m_gid (0), m_mem (), m_valid (false)
49 { }
50
51 group (const group& gr)
52 : m_name (gr.m_name), m_passwd (gr.m_passwd),
53 m_gid (gr.m_gid), m_mem (gr.m_mem), m_valid (gr.m_valid)
54 { }
55
56 group& operator = (const group& gr)
57 {
58 if (this != &gr)
59 {
60 m_name = gr.m_name;
61 m_passwd = gr.m_passwd;
62 m_gid = gr.m_gid;
63 m_mem = gr.m_mem;
64 m_valid = gr.m_valid;
65 }
66
67 return *this;
68 }
69
70 std::string name (void) const;
71
72 std::string passwd (void) const;
73
74 gid_t gid (void) const;
75
76 string_vector mem (void) const;
77
78 bool ok (void) const { return m_valid; }
79
80 operator bool () const { return ok (); }
81
82 static group getgrent (void);
83 static group getgrent (std::string& msg);
84
85 static group getgrgid (gid_t gid);
86 static group getgrgid (gid_t gid, std::string& msg);
87
88 static group getgrnam (const std::string& nm);
89 static group getgrnam (const std::string& nm, std::string& msg);
90
91 static int setgrent (void);
92 static int setgrent (std::string& msg);
93
94 static int endgrent (void);
95 static int endgrent (std::string& msg);
96
97 private:
98
99 // The group name.
100 std::string m_name;
101
102 // The group password.
103 std::string m_passwd;
104
105 // The numeric group id.
106 gid_t m_gid;
107
108 // The members of the group;
110
111 // Flag that says whether we have been properly initialized.
113
114 // This is how we will create an group object from a pointer
115 // to a struct group.
116 group (void *p, std::string& msg);
117 };
118 }
119}
120
121#endif
string_vector m_mem
Definition: oct-group.h:109
bool ok(void) const
Definition: oct-group.h:78
std::string m_passwd
Definition: oct-group.h:103
group(const group &gr)
Definition: oct-group.h:51
std::string m_name
Definition: oct-group.h:100
QString name
#define OCTAVE_API
Definition: main.in.cc:55