3
Copyright (C) 1996, 1997, 2000, 2002, 2003, 2005, 2006, 2007
6
This file is part of Octave.
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
28
#ifdef HAVE_SYS_TYPES_H
29
#include <sys/types.h>
37
#include "oct-group.h"
40
#define NOT_SUPPORTED(nm) \
41
nm ": not supported on this system"
44
octave_group::name (void) const
53
octave_group::passwd (void) const
62
octave_group::gid (void) const
71
octave_group::mem (void) const
80
octave_group::getgrent (void)
83
return getgrent (msg);
87
octave_group::getgrent (std::string& msg)
89
#if defined (HAVE_GETGRENT)
91
return octave_group (::getgrent (), msg);
93
msg = NOT_SUPPORTED ("getgrent");
94
return octave_group ();
99
octave_group::getgrgid (gid_t gid)
102
return getgrgid (gid, msg);
106
octave_group::getgrgid (gid_t gid, std::string& msg)
108
#if defined (HAVE_GETGRGID)
109
msg = std::string ();
110
return octave_group (::getgrgid (gid), msg);
112
msg = NOT_SUPPORTED ("getgruid");
113
return octave_group ();
118
octave_group::getgrnam (const std::string& nm)
121
return getgrnam (nm, msg);
125
octave_group::getgrnam (const std::string& nm, std::string& msg)
127
#if defined (HAVE_GETGRNAM)
128
msg = std::string ();
129
return octave_group (::getgrnam (nm.c_str ()), msg);
131
msg = NOT_SUPPORTED ("getgrnam");
132
return octave_group ();
137
octave_group::setgrent (void)
140
return setgrent (msg);
144
octave_group::setgrent (std::string& msg)
146
#if defined (HAVE_SETGRENT)
147
msg = std::string ();
151
msg = NOT_SUPPORTED ("setgrent");
157
octave_group::endgrent (void)
160
return endgrent (msg);
164
octave_group::endgrent (std::string& msg)
166
#if defined (HAVE_ENDGRENT)
167
msg = std::string ();
171
msg = NOT_SUPPORTED ("endgrent");
176
octave_group::octave_group (void *p, std::string& msg)
177
: gr_name (), gr_passwd (), gr_gid (0), gr_mem (), valid (false)
179
#if defined (HAVE_GRP_H)
180
msg = std::string ();
184
struct group *gr = static_cast<struct group *> (p);
186
gr_name = gr->gr_name;
188
#if defined (HAVE_GR_PASSWD)
189
gr_passwd = gr->gr_passwd;
194
// FIXME -- maybe there should be a string_vector
195
// constructor that takes a NULL terminated list of C
198
const char * const *tmp = gr->gr_mem;
210
for (int i = 0; i < k; i++)
217
msg = NOT_SUPPORTED ("group functions");
222
octave_group::gripe_invalid (void) const
224
(*current_liboctave_error_handler) ("invalid group object");
228
;;; Local Variables: ***