26#if defined (HAVE_CONFIG_H)
49mk_gr_map (
const sys::group& gr)
55 m.
assign (
"name", gr.name ());
56 m.
assign (
"passwd", gr.passwd ());
57 m.
assign (
"gid",
static_cast<double> (gr.gid ()));
66DEFUN (getgrent, args, ,
75 if (args.length () != 0)
81 octave_value val = mk_gr_map (sys::group::getgrent (msg));
83 return ovl (val, msg);
86DEFUN (getgrgid, args, ,
96 if (args.length () != 1)
99 double dval = args(0).double_value ();
101 if (math::x_nint (dval) != dval)
102 error (
"getgrgid: GID must be an integer");
104 gid_t gid =
static_cast<gid_t
> (dval);
109 octave_value val = mk_gr_map (sys::group::getgrgid (gid, msg));
111 return ovl (val, msg);
114DEFUN (getgrnam, args, ,
124 if (args.length () != 1)
127 std::string s = args(0).string_value ();
132 octave_value val = mk_gr_map (sys::group::getgrnam (s.c_str (), msg));
134 return ovl (val, msg);
137DEFUN (setgrent, args, ,
144 if (args.length () != 0)
150 int status = sys::group::setgrent (msg);
152 return ovl (
static_cast<double> (status), msg);
155DEFUN (endgrent, args, ,
162 if (args.length () != 0)
168 int status = sys::group::endgrent (msg);
170 return ovl (
static_cast<double> (status), msg);
173OCTAVE_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.