annotate libinterp/corefcn/getpwent.cc @ 17289:bc924baa2c4e

doc: Add new @qcode macro for code samples which are quoted. Macro handles options ("on") or properties ("position") more elegantly than @code{"text"}. * doc/interpreter/macros.texi: Add new @qcode macro. * doc/interpreter/tips.txi: Add documentation about @qcode macro. * doc/interpreter/basics.txi, doc/interpreter/container.txi, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/func.txi, doc/interpreter/grammar.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/io.txi, doc/interpreter/matrix.txi, doc/interpreter/numbers.txi, doc/interpreter/oop.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/quad.txi, doc/interpreter/sparse.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m, scripts/general/dblquad.m, scripts/general/display.m, scripts/general/genvarname.m, scripts/general/idivide.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m, scripts/general/profexplore.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/triplequad.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m, scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/javaclasspath.m, scripts/java/usejava.m, scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m, scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m, scripts/optimization/fminunc.m, scripts/optimization/fsolve.m, scripts/optimization/fzero.m, scripts/optimization/glpk.m, scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m, scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m, scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m, scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m, scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m, scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m, scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m, scripts/plot/plot.m, scripts/plot/print.m, scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m, scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m, scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m, scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m, scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m, scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m, scripts/polynomial/conv.m, scripts/polynomial/polyout.m, scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m, scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m, scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m, scripts/signal/periodogram.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m, scripts/specfun/legendre.m, scripts/special-matrix/gallery.m, scripts/statistics/base/mean.m, scripts/statistics/base/moment.m, scripts/statistics/tests/cor_test.m, scripts/statistics/tests/kolmogorov_smirnov_test.m, scripts/statistics/tests/kolmogorov_smirnov_test_2.m, scripts/statistics/tests/kruskal_wallis_test.m, scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m, scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m, scripts/statistics/tests/t_test_regression.m, scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m, scripts/statistics/tests/welch_test.m, scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m, scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m, scripts/strings/index.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/validatestring.m, scripts/testfun/demo.m, scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m, scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m, scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author Rik <rik@octave.org>
date Mon, 19 Aug 2013 20:46:38 -0700
parents 2fc554ffbc28
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
1 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14022
diff changeset
3 Copyright (C) 1996-2012 John W. Eaton
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
4
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
6
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
10 option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
11
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
15 for more details.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
16
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5823
diff changeset
19 <http://www.gnu.org/licenses/>.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
20
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
21 */
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
22
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
25 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
26
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
27 #include <string>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29 #include <sys/types.h>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
30
2933
b53d9b2acd88 [project @ 1997-05-05 22:50:28 by jwe]
jwe
parents: 2928
diff changeset
31 #include "oct-passwd.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
32
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
33 #include "defun.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
34 #include "error.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
35 #include "gripes.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36 #include "oct-map.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
37 #include "ov.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38 #include "oct-obj.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
39 #include "utils.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
40
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
41 // Password file functions. (Why not?)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
42
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
43 static octave_value
2933
b53d9b2acd88 [project @ 1997-05-05 22:50:28 by jwe]
jwe
parents: 2928
diff changeset
44 mk_pw_map (const octave_passwd& pw)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
45 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
46 octave_value retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
47
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
48 if (pw)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
49 {
11043
e9966851619b getpwent.cc, getgrent.cc, getrusage.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10182
diff changeset
50 octave_scalar_map m;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
51
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
52 m.assign ("name", pw.name ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
53 m.assign ("passwd", pw.passwd ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
54 m.assign ("uid", static_cast<double> (pw.uid ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
55 m.assign ("gid", static_cast<double> (pw.gid ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
56 m.assign ("gecos", pw.gecos ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
57 m.assign ("dir", pw.dir ());
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4391
diff changeset
58 m.assign ("shell", pw.shell ());
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
59
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
60 retval = m;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
61 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
62 else
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 3523
diff changeset
63 retval = 0;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
64
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
65 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
66 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
67
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
68 DEFUN (getpwent, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
69 "-*- texinfo -*-\n\
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
70 @deftypefn {Built-in Function} {@var{pw_struct} =} getpwent ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
71 Return a structure containing an entry from the password database,\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
72 opening it if necessary. Once the end of the data has been reached,\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
73 @code{getpwent} returns 0.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
74 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
75 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
76 octave_value_list retval;
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
77
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
78 retval(1) = std::string ();
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 3523
diff changeset
79 retval(0) = 0;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
80
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
81 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
82
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
83 if (nargin == 0)
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
84 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
85 std::string msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
86
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
87 retval(1) = msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
88 retval(0) = mk_pw_map (octave_passwd::getpwent (msg));
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
89 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
90 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5307
diff changeset
91 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
92
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
93 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
94 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
95
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
96 DEFUN (getpwuid, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
97 "-*- texinfo -*-\n\
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
98 @deftypefn {Built-in Function} {@var{pw_struct} =} getpwuid (@var{uid}).\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
99 Return a structure containing the first entry from the password database\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
100 with the user ID @var{uid}. If the user ID does not exist in the\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
101 database, @code{getpwuid} returns 0.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
102 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
103 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
104 octave_value_list retval;
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
105
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
106 retval(1) = std::string ();
4233
ccfdb55c8156 [project @ 2002-12-20 22:43:54 by jwe]
jwe
parents: 3523
diff changeset
107 retval(0) = 0;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
108
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
109 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
110
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
111 if (nargin == 1)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
112 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
113 double dval = args(0).double_value ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
114
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
115 if (! error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
116 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
117 if (D_NINT (dval) == dval)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
118 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
119 uid_t uid = static_cast<uid_t> (dval);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
120
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
121 std::string msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
122
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
123 retval(1) = msg;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
124 retval(0) = mk_pw_map (octave_passwd::getpwuid (uid, msg));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
125 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
126 else
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
127 error ("getpwuid: UID must be an integer");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
128 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
129 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
130 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5307
diff changeset
131 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
132
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
133 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
134 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
135
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
136 DEFUN (getpwnam, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
137 "-*- texinfo -*-\n\
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
138 @deftypefn {Built-in Function} {@var{pw_struct} =} getpwnam (@var{name})\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
139 Return a structure containing the first entry from the password database\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
140 with the user name @var{name}. If the user name does not exist in the\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
141 database, @code{getpwname} returns 0.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
142 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
143 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
144 octave_value_list retval;
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
145
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
146 retval(1) = std::string ();
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
147 retval(0) = 0.0;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
148
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
149 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
150
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
151 if (nargin == 1)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
152 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
153 std::string s = args(0).string_value ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
154
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
155 if (! error_state)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
156 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
157 std::string msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
158
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
159 retval(1) = msg;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
160 retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 9064
diff changeset
161 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
162 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
163 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5307
diff changeset
164 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
165
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
166 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
167 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
168
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
169 DEFUN (setpwent, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
170 "-*- texinfo -*-\n\
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
171 @deftypefn {Built-in Function} {} setpwent ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
172 Return the internal pointer to the beginning of the password database.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
173 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
174 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
175 octave_value_list retval;
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
176
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
177 retval(1) = std::string ();
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
178 retval(0) = -1.0;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
179
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
180 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
181
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
182 if (nargin == 0)
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
183 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
184 std::string msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
185
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
186 retval(1) = msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
187 retval(0) = static_cast<double> (octave_passwd::setpwent (msg));
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
188 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
189 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5307
diff changeset
190 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
191
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
192 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
193 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
194
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
195 DEFUN (endpwent, args, ,
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
196 "-*- texinfo -*-\n\
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14138
diff changeset
197 @deftypefn {Built-in Function} {} endpwent ()\n\
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
198 Close the password database.\n\
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3014
diff changeset
199 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
200 {
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
201 octave_value_list retval;
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
202
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
203 retval(1) = std::string ();
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
204 retval(0) = -1.0;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
205
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
206 int nargin = args.length ();
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
207
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
208 if (nargin == 0)
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
209 {
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
210 std::string msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
211
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 11553
diff changeset
212 retval(1) = msg;
2937
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
213 retval(0) = static_cast<double> (octave_passwd::endpwent (msg));
9d26524e2869 [project @ 1997-05-06 05:49:53 by jwe]
jwe
parents: 2933
diff changeset
214 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
215 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5307
diff changeset
216 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
217
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
218 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
219 }