26 #if defined (HAVE_CONFIG_H)
32 #include <sys/types.h>
49 mk_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 ());
71 DEFUN (getpwent, args, ,
81 if (args.length () != 0)
87 octave_value val = mk_pw_map (sys::password::getpwent (msg));
89 return ovl (val, msg);
92 DEFUN (getpwuid, args, ,
102 if (args.length () != 1)
105 double dval = args(0).double_value ();
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);
120 DEFUN (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);
143 DEFUN (setpwent, args, ,
150 if (args.length () != 0)
156 int status = sys::password::setpwent (msg);
158 return ovl (
static_cast<double> (status), msg);
161 DEFUN (endpwent, args, ,
168 if (args.length () != 0)
174 int status = sys::password::endpwent (msg);
176 return ovl (
static_cast<double> (status), msg);
179 OCTAVE_END_NAMESPACE(
octave)
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,...)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.