GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-group.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_oct_group_h)
24 #define octave_oct_group_h 1
25 
26 #include <string>
27 
28 #include <sys/types.h>
29 
30 #include "str-vec.h"
31 
32 class
33 OCTAVE_API
35 {
36 public:
37 
38  octave_group (void)
39  : gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false)
40  { }
41 
43  : gr_name (gr.gr_name), gr_passwd (gr.gr_passwd),
44  gr_gid (gr.gr_gid), gr_mem (gr.gr_mem), valid (gr.valid)
45  { }
46 
47  octave_group& operator = (const octave_group& gr)
48  {
49  if (this != &gr)
50  {
51  gr_name = gr.gr_name;
52  gr_passwd = gr.gr_passwd;
53  gr_gid = gr.gr_gid;
54  gr_mem = gr.gr_mem;
55  valid = gr.valid;
56  }
57 
58  return *this;
59  }
60 
61  std::string name (void) const;
62 
63  std::string passwd (void) const;
64 
65  gid_t gid (void) const;
66 
67  string_vector mem (void) const;
68 
69  bool ok (void) const { return valid; }
70 
71  operator bool () const { return ok (); }
72 
73  static octave_group getgrent (void);
74  static octave_group getgrent (std::string& msg);
75 
76  static octave_group getgrgid (gid_t gid);
77  static octave_group getgrgid (gid_t gid, std::string& msg);
78 
79  static octave_group getgrnam (const std::string& nm);
80  static octave_group getgrnam (const std::string& nm, std::string& msg);
81 
82  static int setgrent (void);
83  static int setgrent (std::string& msg);
84 
85  static int endgrent (void);
86  static int endgrent (std::string& msg);
87 
88 private:
89 
90  // The group name.
91  std::string gr_name;
92 
93  // The group password.
94  std::string gr_passwd;
95 
96  // The numeric group id.
97  gid_t gr_gid;
98 
99  // The members of the group;
101 
102  // Flag that says whether we have been properly initialized.
103  bool valid;
104 
105  // This is how we will create an octave_group object from a pointer
106  // to a struct group.
107  octave_group (void *p, std::string& msg);
108 
109  void gripe_invalid (void) const;
110 };
111 
112 #endif
int bool
Definition: mex.h:56
bool ok(void) const
Definition: oct-group.h:69
octave_group(const octave_group &gr)
Definition: oct-group.h:42
octave_group(void)
Definition: oct-group.h:38
std::string gr_passwd
Definition: oct-group.h:94
string_vector gr_mem
Definition: oct-group.h:100
std::string gr_name
Definition: oct-group.h:91
gid_t gr_gid
Definition: oct-group.h:97