26#if defined (HAVE_CONFIG_H)
49mk_pw_map (
const sys::password& pw)
57 m.
assign (
"name", pw.name ());
58 m.
assign (
"passwd", pw.passwd ());
59 m.
assign (
"uid",
static_cast<double> (pw.uid ()));
60 m.
assign (
"gid",
static_cast<double> (pw.gid ()));
61 m.
assign (
"gecos", pw.gecos ());
62 m.
assign (
"dir", pw.dir ());
63 m.
assign (
"shell", pw.shell ());
71DEFUN (getpwent, args, ,
81 if (args.length () != 0)
87 octave_value val = mk_pw_map (sys::password::getpwent (msg));
89 return ovl (val, msg);
92DEFUN (getpwuid, args, ,
102 if (args.length () != 1)
105 double dval = args(0).double_value ();
107 if (math::x_nint (dval) != dval)
108 error (
"getpwuid: UID must be an integer");
110 uid_t uid =
static_cast<uid_t
> (dval);
115 octave_value val = mk_pw_map (sys::password::getpwuid (uid, msg));
117 return ovl (val, msg);
120DEFUN (getpwnam, args, ,
130 if (args.length () != 1)
133 std::string s = args(0).string_value ();
138 octave_value val = mk_pw_map (sys::password::getpwnam (s, msg));
140 return ovl (val, msg);
143DEFUN (setpwent, args, ,
150 if (args.length () != 0)
156 int status = sys::password::setpwent (msg);
158 return ovl (
static_cast<double> (status), msg);
161DEFUN (endpwent, args, ,
168 if (args.length () != 0)
174 int status = sys::password::endpwent (msg);
176 return ovl (
static_cast<double> (status), msg);
179OCTAVE_END_NAMESPACE(octave)
void assign(const std::string &k, const octave_value &val)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.