GNU Octave
11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Loading...
Searching...
No Matches
oct-password.h
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 1996-2026 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_passwd_h)
27
#define octave_oct_passwd_h 1
28
29
#include "octave-config.h"
30
31
#include <string>
32
33
#include <sys/types.h>
34
35
OCTAVE_BEGIN_NAMESPACE
(octave)
36
OCTAVE_BEGIN_NAMESPACE
(sys)
37
38
class
OCTAVE_API
password
39
{
40
public
:
41
42
password
()
43
: m_name (), m_passwd (), m_uid (0), m_gid (0), m_gecos (),
44
m_dir (), m_shell (), m_valid (false)
45
{ }
46
47
password
(
const
password
& pw)
48
: m_name (pw.m_name), m_passwd (pw.m_passwd),
49
m_uid (pw.m_uid), m_gid (pw.m_gid), m_gecos (pw.m_gecos),
50
m_dir (pw.m_dir), m_shell (pw.m_shell), m_valid (pw.m_valid)
51
{ }
52
53
password
& operator = (
const
password
& pw)
54
{
55
if
(
this
!= &pw)
56
{
57
m_name = pw.m_name;
58
m_passwd = pw.m_passwd;
59
m_uid = pw.m_uid;
60
m_gid = pw.m_gid;
61
m_gecos = pw.m_gecos;
62
m_dir = pw.m_dir;
63
m_shell = pw.m_shell;
64
m_valid = pw.m_valid;
65
}
66
67
return
*
this
;
68
}
69
70
~password
() =
default
;
71
72
std::string name ()
const
;
73
74
std::string passwd ()
const
;
75
76
uid_t uid ()
const
;
77
78
gid_t gid ()
const
;
79
80
std::string gecos ()
const
;
81
82
std::string dir ()
const
;
83
84
std::string shell ()
const
;
85
86
bool
ok
()
const
{
return
m_valid; }
87
88
operator
bool
()
const
{
return
ok (); }
89
90
static
password
getpwent ();
91
static
password
getpwent (std::string& msg);
92
93
static
password
getpwuid (uid_t uid);
94
static
password
getpwuid (uid_t uid, std::string& msg);
95
96
static
password
getpwnam (
const
std::string& nm);
97
static
password
getpwnam (
const
std::string& nm, std::string& msg);
98
99
static
int
setpwent ();
100
static
int
setpwent (std::string& msg);
101
102
static
int
endpwent ();
103
static
int
endpwent (std::string& msg);
104
105
private
:
106
107
// User name.
108
std::string m_name;
109
110
// Encrypted password.
111
std::string m_passwd;
112
113
// Numeric user id.
114
uid_t m_uid;
115
116
// Numeric group id.
117
gid_t m_gid;
118
119
// Miscellaneous junk.
120
std::string m_gecos;
121
122
// Home directory.
123
std::string m_dir;
124
125
// Login shell.
126
std::string m_shell;
127
128
// Flag that says whether we have been properly initialized.
129
bool
m_valid;
130
131
// This is how we will create a password object from a pointer
132
// to a struct passwd.
133
password
(
void
*p, std::string& msg);
134
};
135
136
OCTAVE_END_NAMESPACE(sys)
137
OCTAVE_END_NAMESPACE(octave)
138
139
#endif
bool
password
Definition
oct-password.h:39
password::~password
~password()=default
password::password
password(const password &pw)
Definition
oct-password.h:47
password::ok
bool ok() const
Definition
oct-password.h:86
password::password
password()
Definition
oct-password.h:42
OCTAVE_BEGIN_NAMESPACE
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTAVE_API
#define OCTAVE_API
Definition
main.in.cc:55
liboctave
system
oct-password.h
Generated on Tue Feb 24 2026 04:49:08 for GNU Octave by
1.9.8