GNU Octave  4.2.1
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-2017 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 "octave-config.h"
27 
28 #include <string>
29 
30 #include <sys/types.h>
31 
32 #include "str-vec.h"
33 
34 namespace octave
35 {
36  namespace sys
37  {
38  class
39  OCTAVE_API
40  group
41  {
42  public:
43 
44  group (void)
45  : m_name (), m_passwd (), m_gid (0), m_mem (), valid (false)
46  { }
47 
48  group (const group& gr)
49  : m_name (gr.m_name), m_passwd (gr.m_passwd),
50  m_gid (gr.m_gid), m_mem (gr.m_mem), valid (gr.valid)
51  { }
52 
53  group& operator = (const group& gr)
54  {
55  if (this != &gr)
56  {
57  m_name = gr.m_name;
58  m_passwd = gr.m_passwd;
59  m_gid = gr.m_gid;
60  m_mem = gr.m_mem;
61  valid = gr.valid;
62  }
63 
64  return *this;
65  }
66 
67  std::string name (void) const;
68 
69  std::string passwd (void) const;
70 
71  gid_t gid (void) const;
72 
73  string_vector mem (void) const;
74 
75  bool ok (void) const { return valid; }
76 
77  operator bool () const { return ok (); }
78 
79  static group getgrent (void);
80  static group getgrent (std::string& msg);
81 
82  static group getgrgid (gid_t gid);
83  static group getgrgid (gid_t gid, std::string& msg);
84 
85  static group getgrnam (const std::string& nm);
86  static group getgrnam (const std::string& nm, std::string& msg);
87 
88  static int setgrent (void);
89  static int setgrent (std::string& msg);
90 
91  static int endgrent (void);
92  static int endgrent (std::string& msg);
93 
94  private:
95 
96  // The group name.
98 
99  // The group password.
101 
102  // The numeric group id.
103  gid_t m_gid;
104 
105  // The members of the group;
107 
108  // Flag that says whether we have been properly initialized.
109  bool valid;
110 
111  // This is how we will create an group object from a pointer
112  // to a struct group.
113  group (void *p, std::string& msg);
114  };
115  }
116 }
117 
118 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
119 
120 OCTAVE_DEPRECATED ("use 'octave::sys::group' instead")
121 typedef octave::sys::group octave_group;
122 
123 #endif
124 
125 #endif
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
string_vector m_mem
Definition: oct-group.h:106
group(const group &gr)
Definition: oct-group.h:48
bool ok(void) const
Definition: oct-group.h:75
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
std::string m_passwd
Definition: oct-group.h:100
is false
Definition: cellfun.cc:398
std::string m_name
Definition: oct-group.h:97
p
Definition: lu.cc:138
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854