Mercurial > hg > octave-lyh
annotate src/syscalls.cc @ 14111:c5222658dc3c stable
doc: Build documentation for functions even when they are unavailable
on a particular platform due to lack of libraries.
syscalls.cc (F_DUPFD, F_GETFD, F_GETFL, F_SETFD, F_SETFL, O_APPEND, O_ASYNC,
O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY):
Build documentation for functions even when they are not available
due to lack of libraries.
__init_fltk__.cc (Fgui_mode, Fmouse_wheel_zoom): Build documentation
for functions even when they are not available due to lack of libraries.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 26 Dec 2011 10:38:45 -0800 |
parents | de90542b7afc |
children | 72c96de7a403 |
rev | line source |
---|---|
2075 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10336
diff
changeset
|
4 Copyright (C) 2010 VZLU Prague |
2075 | 5 |
6 This file is part of Octave. | |
7 | |
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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2075 | 12 |
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 | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2075 | 21 |
22 */ | |
23 | |
24 // Thomas Baier <baier@ci.tuwien.ac.at> added the original versions of | |
25 // the following functions: | |
26 // | |
27 // mkfifo unlink waitpid | |
28 | |
29 #ifdef HAVE_CONFIG_H | |
30 #include <config.h> | |
31 #endif | |
32 | |
33 #include <cstdio> | |
2669 | 34 #include <cstring> |
2075 | 35 |
36 #include <sys/types.h> | |
37 #include <unistd.h> | |
38 | |
39 #include <fcntl.h> | |
40 | |
2926 | 41 #include "file-ops.h" |
42 #include "file-stat.h" | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
43 #include "oct-env.h" |
2937 | 44 #include "oct-syscalls.h" |
5547 | 45 #include "oct-uname.h" |
2926 | 46 |
2075 | 47 #include "defun.h" |
48 #include "error.h" | |
2078 | 49 #include "gripes.h" |
2075 | 50 #include "lo-utils.h" |
51 #include "oct-map.h" | |
52 #include "oct-obj.h" | |
53 #include "oct-stdstrm.h" | |
54 #include "oct-stream.h" | |
55 #include "sysdep.h" | |
56 #include "utils.h" | |
2366 | 57 #include "variables.h" |
6321 | 58 #include "input.h" |
2075 | 59 |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
60 static octave_scalar_map |
8549 | 61 mk_stat_map (const base_file_stat& fs) |
2075 | 62 { |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
63 octave_scalar_map m; |
2075 | 64 |
4675 | 65 m.assign ("dev", static_cast<double> (fs.dev ())); |
66 m.assign ("ino", fs.ino ()); | |
5476 | 67 m.assign ("mode", fs.mode ()); |
4675 | 68 m.assign ("modestr", fs.mode_as_string ()); |
69 m.assign ("nlink", fs.nlink ()); | |
70 m.assign ("uid", fs.uid ()); | |
71 m.assign ("gid", fs.gid ()); | |
3887 | 72 #if defined (HAVE_STRUCT_STAT_ST_RDEV) |
4675 | 73 m.assign ("rdev", static_cast<double> (fs.rdev ())); |
2075 | 74 #endif |
4675 | 75 m.assign ("size", fs.size ()); |
76 m.assign ("atime", fs.atime ()); | |
77 m.assign ("mtime", fs.mtime ()); | |
78 m.assign ("ctime", fs.ctime ()); | |
3887 | 79 #if defined (HAVE_STRUCT_STAT_ST_BLKSIZE) |
4675 | 80 m.assign ("blksize", fs.blksize ()); |
2075 | 81 #endif |
3887 | 82 #if defined (HAVE_STRUCT_STAT_ST_BLOCKS) |
4675 | 83 m.assign ("blocks", fs.blocks ()); |
2075 | 84 #endif |
85 | |
86 return m; | |
87 } | |
88 | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
89 static octave_value_list |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
90 mk_stat_result (const base_file_stat& fs) |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
91 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
92 octave_value_list retval; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
93 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
94 if (fs) |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
95 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
96 retval(2) = std::string (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
97 retval(1) = 0; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
98 retval(0) = octave_value (mk_stat_map (fs)); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
99 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
100 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
101 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
102 retval(2) = fs.error (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
103 retval(1) = -1; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
104 retval(0) = Matrix (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
105 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
106 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
107 return retval; |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
108 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
109 |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
110 DEFUNX ("dup2", Fdup2, args, , |
3301 | 111 "-*- texinfo -*-\n\ |
112 @deftypefn {Built-in Function} {[@var{fid}, @var{msg}] =} dup2 (@var{old}, @var{new})\n\ | |
2669 | 113 Duplicate a file descriptor.\n\ |
114 \n\ | |
3301 | 115 If successful, @var{fid} is greater than zero and contains the new file\n\ |
10840 | 116 ID@. Otherwise, @var{fid} is negative and @var{msg} contains a\n\ |
3301 | 117 system-dependent error message.\n\ |
118 @end deftypefn") | |
2075 | 119 { |
2669 | 120 octave_value_list retval; |
121 | |
3523 | 122 retval(1) = std::string (); |
4294 | 123 retval(0) = -1; |
2075 | 124 |
125 int nargin = args.length (); | |
126 | |
127 if (nargin == 2) | |
128 { | |
3341 | 129 octave_stream old_stream |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
130 = octave_stream_list::lookup (args(0), "dup2"); |
2075 | 131 |
3341 | 132 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
133 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
134 octave_stream new_stream |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
135 = octave_stream_list::lookup (args(1), "dup2"); |
2075 | 136 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
137 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
138 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
139 int i_old = old_stream.file_number (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
140 int i_new = new_stream.file_number (); |
2937 | 141 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
142 if (i_old >= 0 && i_new >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
143 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
144 std::string msg; |
2669 | 145 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
146 int status = octave_syscalls::dup2 (i_old, i_new, msg); |
3341 | 147 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
148 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
149 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
150 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
151 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
152 } |
3145 | 153 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
154 error ("dup2: invalid stream"); |
2075 | 155 } |
156 else | |
5823 | 157 print_usage (); |
2075 | 158 |
159 return retval; | |
160 } | |
161 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
162 DEFUNX ("exec", Fexec, args, , |
3301 | 163 "-*- texinfo -*-\n\ |
164 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} exec (@var{file}, @var{args})\n\ | |
165 Replace current process with a new process. Calling @code{exec} without\n\ | |
166 first calling @code{fork} will terminate your current Octave process and\n\ | |
167 replace it with the program named by @var{file}. For example,\n\ | |
2669 | 168 \n\ |
3301 | 169 @example\n\ |
170 exec (\"ls\" \"-l\")\n\ | |
171 @end example\n\ | |
2669 | 172 \n\ |
3301 | 173 @noindent\n\ |
174 will run @code{ls} and return you to your shell prompt.\n\ | |
175 \n\ | |
176 If successful, @code{exec} does not return. If @code{exec} does return,\n\ | |
177 @var{err} will be nonzero, and @var{msg} will contain a system-dependent\n\ | |
178 error message.\n\ | |
179 @end deftypefn") | |
2075 | 180 { |
2669 | 181 octave_value_list retval; |
182 | |
3523 | 183 retval(1) = std::string (); |
4294 | 184 retval(0) = -1; |
2075 | 185 |
186 int nargin = args.length (); | |
187 | |
188 if (nargin == 1 || nargin == 2) | |
189 { | |
3523 | 190 std::string exec_file = args(0).string_value (); |
2075 | 191 |
192 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
193 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
194 string_vector exec_args; |
2075 | 195 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
196 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
197 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
198 string_vector tmp = args(1).all_strings (); |
2075 | 199 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
200 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
201 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
202 int len = tmp.length (); |
2075 | 203 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
204 exec_args.resize (len + 1); |
2075 | 205 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
206 exec_args[0] = exec_file; |
2075 | 207 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
208 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
209 exec_args[i+1] = tmp[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
210 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
211 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
212 error ("exec: arguments must be character strings"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
213 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
214 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
215 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
216 exec_args.resize (1); |
2075 | 217 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
218 exec_args[0] = exec_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
219 } |
2075 | 220 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
221 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
222 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
223 std::string msg; |
2937 | 224 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
225 int status = octave_syscalls::execvp (exec_file, exec_args, msg); |
2669 | 226 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
227 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
228 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
229 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
230 } |
2075 | 231 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
232 error ("exec: FILE must be a string"); |
2075 | 233 } |
234 else | |
5823 | 235 print_usage (); |
2075 | 236 |
237 return retval; | |
238 } | |
239 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
240 DEFUNX ("popen2", Fpopen2, args, , |
6321 | 241 "-*- texinfo -*-\n\ |
6678 | 242 @deftypefn {Built-in Function} {[@var{in}, @var{out}, @var{pid}] =} popen2 (@var{command}, @var{args})\n\ |
6321 | 243 Start a subprocess with two-way communication. The name of the process\n\ |
244 is given by @var{command}, and @var{args} is an array of strings\n\ | |
245 containing options for the command. The file identifiers for the input\n\ | |
246 and output streams of the subprocess are returned in @var{in} and\n\ | |
247 @var{out}. If execution of the command is successful, @var{pid}\n\ | |
248 contains the process ID of the subprocess. Otherwise, @var{pid} is\n\ | |
249 @minus{}1.\n\ | |
250 \n\ | |
10840 | 251 For example:\n\ |
6321 | 252 \n\ |
253 @example\n\ | |
6923 | 254 [in, out, pid] = popen2 (\"sort\", \"-r\");\n\ |
6321 | 255 fputs (in, \"these\\nare\\nsome\\nstrings\\n\");\n\ |
256 fclose (in);\n\ | |
257 EAGAIN = errno (\"EAGAIN\");\n\ | |
258 done = false;\n\ | |
259 do\n\ | |
260 s = fgets (out);\n\ | |
261 if (ischar (s))\n\ | |
262 fputs (stdout, s);\n\ | |
263 elseif (errno () == EAGAIN)\n\ | |
264 sleep (0.1);\n\ | |
265 fclear (out);\n\ | |
266 else\n\ | |
267 done = true;\n\ | |
268 endif\n\ | |
269 until (done)\n\ | |
270 fclose (out);\n\ | |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
271 waitpid (pid);\n\ |
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
272 @print{} these\n\ |
6321 | 273 @print{} strings\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
274 @print{} some\n\ |
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
275 @print{} are\n\ |
6321 | 276 @end example\n\ |
9563
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
277 \n\ |
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
278 Note that @code{popen2}, unlike @code{popen}, will not \"reap\" the\n\ |
f5c28d8f5147
syscalls.cc: Recommend waitpid() in popen2() documentation.
Rob Mahurin <rob@utk.edu>
parents:
9209
diff
changeset
|
279 child process. If you don't use @code{waitpid} to check the child's\n\ |
9564 | 280 exit status, it will linger until Octave exits.\n\ |
6321 | 281 @end deftypefn") |
282 { | |
283 octave_value_list retval; | |
284 | |
285 retval(2) = -1; | |
286 retval(1) = Matrix (); | |
287 retval(0) = Matrix (); | |
288 | |
289 int nargin = args.length (); | |
290 | |
291 if (nargin >= 1 && nargin <= 3) | |
292 { | |
293 std::string exec_file = args(0).string_value(); | |
294 | |
295 if (! error_state) | |
296 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
297 string_vector arg_list; |
6321 | 298 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
299 if (nargin >= 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
300 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
301 string_vector tmp = args(1).all_strings (); |
6321 | 302 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
303 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
304 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
305 int len = tmp.length (); |
6321 | 306 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
307 arg_list.resize (len + 1); |
6321 | 308 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
309 arg_list[0] = exec_file; |
6321 | 310 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
311 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
312 arg_list[i+1] = tmp[i]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
313 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
314 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
315 error ("popen2: arguments must be character strings"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
316 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
317 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
318 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
319 arg_list.resize (1); |
6321 | 320 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
321 arg_list[0] = exec_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
322 } |
6321 | 323 |
324 if (! error_state) | |
325 { | |
326 bool sync_mode = (nargin == 3 ? args(2).bool_value() : false); | |
327 | |
328 if (! error_state) | |
329 { | |
330 int fildes[2]; | |
331 std::string msg; | |
332 pid_t pid; | |
333 | |
334 pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode, fildes, msg, interactive); | |
335 if (pid >= 0) | |
336 { | |
337 FILE *ifile = fdopen (fildes[1], "r"); | |
338 FILE *ofile = fdopen (fildes[0], "w"); | |
339 | |
340 std::string nm; | |
341 | |
342 octave_stream is = octave_stdiostream::create (nm, ifile, | |
343 std::ios::in); | |
344 | |
345 octave_stream os = octave_stdiostream::create (nm, ofile, | |
346 std::ios::out); | |
347 | |
348 Cell file_ids (1, 2); | |
349 | |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
350 retval(2) = pid; |
6321 | 351 retval(1) = octave_stream_list::insert (is); |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
352 retval(0) = octave_stream_list::insert (os); |
6321 | 353 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
354 else |
6321 | 355 error (msg.c_str ()); |
356 } | |
357 } | |
358 else | |
359 error ("popen2: arguments must be character strings"); | |
360 } | |
361 else | |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
362 error ("popen2: COMMAND argument must be a string"); |
6321 | 363 } |
364 else | |
365 print_usage (); | |
366 | |
367 return retval; | |
368 } | |
369 | |
370 /* | |
371 | |
372 %!test | |
373 %! if (isunix()) | |
6923 | 374 %! [in, out, pid] = popen2 ("sort", "-r"); |
6321 | 375 %! EAGAIN = errno ("EAGAIN"); |
376 %! else | |
6322 | 377 %! [in, out, pid] = popen2 ("sort", "/R"); |
6321 | 378 %! EAGAIN = errno ("EINVAL"); |
379 %! endif | |
380 %! fputs (in, "these\nare\nsome\nstrings\n"); | |
381 %! fclose (in); | |
382 %! done = false; | |
383 %! str = {}; | |
384 %! idx = 0; | |
6545 | 385 %! errs = 0; |
6321 | 386 %! do |
387 %! if (!isunix()) | |
388 %! errno (0); | |
389 %! endif | |
390 %! s = fgets (out); | |
391 %! if (ischar (s)) | |
392 %! idx++; | |
393 %! str{idx} = s; | |
394 %! elseif (errno () == EAGAIN) | |
6543 | 395 %! fclear (out); |
6321 | 396 %! sleep (0.1); |
6545 | 397 %! if (++errs == 100) |
398 %! done = true; | |
399 %! endif | |
6321 | 400 %! else |
401 %! done = true; | |
402 %! endif | |
6545 | 403 %! until (done) |
6321 | 404 %! fclose (out); |
6324 | 405 %! if (isunix()) |
6322 | 406 %! assert(str,{"these\n","strings\n","some\n","are\n"}) |
407 %! else | |
408 %! assert(str,{"these\r\n","strings\r\n","some\r\n","are\r\n"}) | |
409 %! end | |
6321 | 410 |
411 */ | |
412 | |
10259 | 413 DEFUNX ("fcntl", Ffcntl, args, , |
3301 | 414 "-*- texinfo -*-\n\ |
415 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} fcntl (@var{fid}, @var{request}, @var{arg})\n\ | |
416 Change the properties of the open file @var{fid}. The following values\n\ | |
417 may be passed as @var{request}:\n\ | |
418 \n\ | |
419 @vtable @code\n\ | |
420 @item F_DUPFD\n\ | |
421 Return a duplicate file descriptor.\n\ | |
422 \n\ | |
423 @item F_GETFD\n\ | |
424 Return the file descriptor flags for @var{fid}.\n\ | |
425 \n\ | |
426 @item F_SETFD\n\ | |
427 Set the file descriptor flags for @var{fid}.\n\ | |
428 \n\ | |
429 @item F_GETFL\n\ | |
430 Return the file status flags for @var{fid}. The following codes may be\n\ | |
431 returned (some of the flags may be undefined on some systems).\n\ | |
432 \n\ | |
433 @vtable @code\n\ | |
434 @item O_RDONLY\n\ | |
435 Open for reading only.\n\ | |
436 \n\ | |
437 @item O_WRONLY\n\ | |
438 Open for writing only.\n\ | |
2669 | 439 \n\ |
3301 | 440 @item O_RDWR\n\ |
441 Open for reading and writing.\n\ | |
442 \n\ | |
443 @item O_APPEND\n\ | |
444 Append on each write.\n\ | |
445 \n\ | |
5040 | 446 @item O_CREAT\n\ |
447 Create the file if it does not exist.\n\ | |
448 \n\ | |
3301 | 449 @item O_NONBLOCK\n\ |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
10762
diff
changeset
|
450 Non-blocking mode.\n\ |
3301 | 451 \n\ |
452 @item O_SYNC\n\ | |
453 Wait for writes to complete.\n\ | |
2669 | 454 \n\ |
3301 | 455 @item O_ASYNC\n\ |
456 Asynchronous I/O.\n\ | |
457 @end vtable\n\ | |
458 \n\ | |
459 @item F_SETFL\n\ | |
460 Set the file status flags for @var{fid} to the value specified by\n\ | |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
461 @var{arg}. The only flags that can be changed are @w{@code{O_APPEND}} and\n\ |
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
462 @w{@code{O_NONBLOCK}}.\n\ |
3301 | 463 @end vtable\n\ |
464 \n\ | |
465 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
466 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
467 system-dependent error message.\n\ | |
468 @end deftypefn") | |
2075 | 469 { |
2669 | 470 octave_value_list retval; |
471 | |
3523 | 472 retval(1) = std::string (); |
4294 | 473 retval(0) = -1; |
2075 | 474 |
475 int nargin = args.length (); | |
476 | |
477 if (nargin == 3) | |
478 { | |
3715 | 479 octave_stream strm = octave_stream_list::lookup (args (0), "fcntl"); |
2075 | 480 |
3202 | 481 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
482 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
483 int fid = strm.file_number (); |
3715 | 484 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
485 int req = args(1).int_value (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
486 int arg = args(2).int_value (true); |
3715 | 487 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
488 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
489 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
490 // FIXME -- Need better checking here? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
491 if (fid < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
492 error ("fcntl: invalid file id"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
493 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
494 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
495 std::string msg; |
2937 | 496 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
497 int status = octave_fcntl (fid, req, arg, msg); |
2669 | 498 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
499 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
500 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
501 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
502 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
503 } |
2075 | 504 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
505 error ("fcntl: FID, REQUEST, and ARG must be integers"); |
2075 | 506 } |
507 else | |
5823 | 508 print_usage (); |
2075 | 509 |
510 return retval; | |
511 } | |
512 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
513 DEFUNX ("fork", Ffork, args, , |
3301 | 514 "-*- texinfo -*-\n\ |
515 @deftypefn {Built-in Function} {[@var{pid}, @var{msg}] =} fork ()\n\ | |
2669 | 516 Create a copy of the current process.\n\ |
517 \n\ | |
3301 | 518 Fork can return one of the following values:\n\ |
519 \n\ | |
520 @table @asis\n\ | |
521 @item > 0\n\ | |
522 You are in the parent process. The value returned from @code{fork} is\n\ | |
523 the process id of the child process. You should probably arrange to\n\ | |
524 wait for any child processes to exit.\n\ | |
525 \n\ | |
526 @item 0\n\ | |
527 You are in the child process. You can call @code{exec} to start another\n\ | |
528 process. If that fails, you should probably call @code{exit}.\n\ | |
529 \n\ | |
530 @item < 0\n\ | |
531 The call to @code{fork} failed for some reason. You must take evasive\n\ | |
532 action. A system dependent error message will be waiting in @var{msg}.\n\ | |
533 @end table\n\ | |
534 @end deftypefn") | |
2075 | 535 { |
2669 | 536 octave_value_list retval; |
537 | |
3523 | 538 retval(1) = std::string (); |
4294 | 539 retval(0) = -1; |
2075 | 540 |
541 int nargin = args.length (); | |
542 | |
543 if (nargin == 0) | |
2475 | 544 { |
3523 | 545 std::string msg; |
2937 | 546 |
547 pid_t pid = octave_syscalls::fork (msg); | |
2669 | 548 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
549 retval(1) = msg; |
4233 | 550 retval(0) = pid; |
2475 | 551 } |
2075 | 552 else |
5823 | 553 print_usage (); |
2075 | 554 |
555 return retval; | |
556 } | |
557 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
558 DEFUNX ("getpgrp", Fgetpgrp, args, , |
3301 | 559 "-*- texinfo -*-\n\ |
560 @deftypefn {Built-in Function} {pgid =} getpgrp ()\n\ | |
561 Return the process group id of the current process.\n\ | |
562 @end deftypefn") | |
2075 | 563 { |
2937 | 564 octave_value_list retval; |
565 | |
3523 | 566 retval(1) = std::string (); |
4294 | 567 retval(0) = -1; |
2075 | 568 |
569 int nargin = args.length (); | |
570 | |
571 if (nargin == 0) | |
2475 | 572 { |
3523 | 573 std::string msg; |
2937 | 574 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
575 retval(1) = msg; |
4233 | 576 retval(0) = octave_syscalls::getpgrp (msg); |
2475 | 577 } |
2075 | 578 else |
5823 | 579 print_usage (); |
2075 | 580 |
581 return retval; | |
582 } | |
583 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
584 DEFUNX ("getpid", Fgetpid, args, , |
3301 | 585 "-*- texinfo -*-\n\ |
586 @deftypefn {Built-in Function} {pid =} getpid ()\n\ | |
587 Return the process id of the current process.\n\ | |
588 @end deftypefn") | |
2075 | 589 { |
4233 | 590 octave_value retval = -1; |
2075 | 591 |
592 int nargin = args.length (); | |
593 | |
594 if (nargin == 0) | |
2937 | 595 retval = octave_syscalls::getpid (); |
2075 | 596 else |
5823 | 597 print_usage (); |
2075 | 598 |
599 return retval; | |
600 } | |
601 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
602 DEFUNX ("getppid", Fgetppid, args, , |
3301 | 603 "-*- texinfo -*-\n\ |
604 @deftypefn {Built-in Function} {pid =} getppid ()\n\ | |
605 Return the process id of the parent process.\n\ | |
606 @end deftypefn") | |
2075 | 607 { |
4233 | 608 octave_value retval = -1; |
2075 | 609 |
2475 | 610 int nargin = args.length (); |
611 | |
612 if (nargin == 0) | |
2937 | 613 retval = octave_syscalls::getppid (); |
2475 | 614 else |
5823 | 615 print_usage (); |
2475 | 616 |
617 return retval; | |
618 } | |
619 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
620 DEFUNX ("getegid", Fgetegid, args, , |
3301 | 621 "-*- texinfo -*-\n\ |
622 @deftypefn {Built-in Function} {egid =} getegid ()\n\ | |
623 Return the effective group id of the current process.\n\ | |
624 @end deftypefn") | |
2475 | 625 { |
4233 | 626 octave_value retval = -1; |
2475 | 627 |
2075 | 628 int nargin = args.length (); |
629 | |
630 if (nargin == 0) | |
4254 | 631 retval = octave_syscalls::getegid (); |
2075 | 632 else |
5823 | 633 print_usage (); |
2475 | 634 |
635 return retval; | |
636 } | |
637 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
638 DEFUNX ("getgid", Fgetgid, args, , |
3301 | 639 "-*- texinfo -*-\n\ |
640 @deftypefn {Built-in Function} {gid =} getgid ()\n\ | |
641 Return the real group id of the current process.\n\ | |
642 @end deftypefn") | |
2475 | 643 { |
4233 | 644 octave_value retval = -1; |
2475 | 645 |
646 int nargin = args.length (); | |
647 | |
648 if (nargin == 0) | |
4254 | 649 retval = octave_syscalls::getgid (); |
2475 | 650 else |
5823 | 651 print_usage (); |
2075 | 652 |
653 return retval; | |
654 } | |
655 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
656 DEFUNX ("geteuid", Fgeteuid, args, , |
3301 | 657 "-*- texinfo -*-\n\ |
658 @deftypefn {Built-in Function} {euid =} geteuid ()\n\ | |
659 Return the effective user id of the current process.\n\ | |
660 @end deftypefn") | |
2472 | 661 { |
4233 | 662 octave_value retval = -1; |
2472 | 663 |
664 int nargin = args.length (); | |
665 | |
666 if (nargin == 0) | |
4254 | 667 retval = octave_syscalls::geteuid (); |
2472 | 668 else |
5823 | 669 print_usage (); |
2473 | 670 |
671 return retval; | |
2472 | 672 } |
673 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
674 DEFUNX ("getuid", Fgetuid, args, , |
3301 | 675 "-*- texinfo -*-\n\ |
676 @deftypefn {Built-in Function} {uid =} getuid ()\n\ | |
677 Return the real user id of the current process.\n\ | |
678 @end deftypefn") | |
2472 | 679 { |
4233 | 680 octave_value retval = -1; |
2472 | 681 |
682 int nargin = args.length (); | |
683 | |
684 if (nargin == 0) | |
4254 | 685 retval = octave_syscalls::getuid (); |
2472 | 686 else |
5823 | 687 print_usage (); |
2473 | 688 |
689 return retval; | |
2472 | 690 } |
691 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
692 DEFUNX ("kill", Fkill, args, , |
4371 | 693 "-*- texinfo -*-\n\ |
4294 | 694 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} kill (@var{pid}, @var{sig})\n\ |
695 Send signal @var{sig} to process @var{pid}.\n\ | |
696 \n\ | |
697 If @var{pid} is positive, then signal @var{sig} is sent to @var{pid}.\n\ | |
698 \n\ | |
699 If @var{pid} is 0, then signal @var{sig} is sent to every process\n\ | |
700 in the process group of the current process.\n\ | |
701 \n\ | |
702 If @var{pid} is -1, then signal @var{sig} is sent to every process\n\ | |
703 except process 1.\n\ | |
704 \n\ | |
705 If @var{pid} is less than -1, then signal @var{sig} is sent to every\n\ | |
706 process in the process group @var{-pid}.\n\ | |
707 \n\ | |
4371 | 708 If @var{sig} is 0, then no signal is sent, but error checking is still\n\ |
4294 | 709 performed.\n\ |
710 \n\ | |
7001 | 711 Return 0 if successful, otherwise return -1.\n\ |
4294 | 712 @end deftypefn") |
713 { | |
714 octave_value_list retval; | |
715 | |
716 retval(1) = std::string (); | |
717 retval(0) = -1; | |
718 | |
719 if (args.length () == 2) | |
720 { | |
721 pid_t pid = args(0).int_value (true); | |
722 | |
723 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
724 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
725 int sig = args(1).int_value (true); |
4294 | 726 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
727 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
728 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
729 std::string msg; |
4294 | 730 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
731 int status = octave_syscalls::kill (pid, sig, msg); |
4294 | 732 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
733 retval(1) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
734 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
735 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
736 } |
4294 | 737 } |
738 else | |
5823 | 739 print_usage (); |
4294 | 740 |
741 return retval; | |
742 } | |
743 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
744 DEFUNX ("lstat", Flstat, args, , |
3458 | 745 "-*- texinfo -*-\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
746 @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{symlink})\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
747 Return a structure @var{info} containing information about the symbolic link\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
748 @var{symlink}. The function outputs are described in the documentation for\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
749 @code{stat}.\n\ |
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
750 @seealso{stat}\n\ |
3458 | 751 @end deftypefn") |
2075 | 752 { |
2263 | 753 octave_value_list retval; |
2075 | 754 |
755 if (args.length () == 1) | |
756 { | |
5872 | 757 std::string fname = args(0).string_value (); |
2075 | 758 |
759 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
760 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
761 file_stat fs (fname, false); |
2075 | 762 |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
763 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
764 } |
2075 | 765 } |
766 else | |
5823 | 767 print_usage (); |
2075 | 768 |
769 return retval; | |
770 } | |
771 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
772 DEFUNX ("mkfifo", Fmkfifo, args, , |
3345 | 773 "-*- texinfo -*-\n\ |
4825 | 774 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\ |
4928 | 775 Create a @var{fifo} special file named @var{name} with file mode @var{mode}\n\ |
2075 | 776 \n\ |
3301 | 777 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
778 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
779 system-dependent error message.\n\ | |
780 @end deftypefn") | |
2075 | 781 { |
2669 | 782 octave_value_list retval; |
783 | |
3523 | 784 retval(1) = std::string (); |
4294 | 785 retval(0) = -1; |
2075 | 786 |
787 int nargin = args.length (); | |
788 | |
789 if (nargin == 2) | |
790 { | |
791 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
792 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
793 std::string name = args(0).string_value (); |
2075 | 794 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
795 if (args(1).is_scalar_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
796 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
797 long mode = args(1).long_value (); |
2075 | 798 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
799 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
800 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
801 std::string msg; |
4254 | 802 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
803 int status = octave_mkfifo (name, mode, msg); |
2669 | 804 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
805 retval(0) = status; |
2669 | 806 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
807 if (status < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
808 retval(1) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
809 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
810 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
811 error ("mkfifo: invalid MODE"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
812 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
813 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
814 error ("mkfifo: MODE must be an integer"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
815 } |
2075 | 816 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
817 error ("mkfifo: FILE must be a string"); |
2075 | 818 } |
819 else | |
5823 | 820 print_usage (); |
2075 | 821 |
822 return retval; | |
823 } | |
824 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
825 DEFUNX ("pipe", Fpipe, args, , |
3301 | 826 "-*- texinfo -*-\n\ |
6321 | 827 @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\ |
828 Create a pipe and return the reading and writing ends of the pipe\n\ | |
829 into @var{read_fd} and @var{write_fd} respectively.\n\ | |
2669 | 830 \n\ |
3301 | 831 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
832 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
833 system-dependent error message.\n\ | |
834 @end deftypefn") | |
2075 | 835 { |
2669 | 836 octave_value_list retval; |
837 | |
6321 | 838 retval(3) = std::string (); |
839 retval(2) = -1; | |
4294 | 840 retval(1) = -1; |
6321 | 841 retval(0) = -1; |
2075 | 842 |
843 int nargin = args.length (); | |
844 | |
845 if (nargin == 0) | |
846 { | |
847 int fid[2]; | |
848 | |
3523 | 849 std::string msg; |
2937 | 850 |
851 int status = octave_syscalls::pipe (fid, msg); | |
2669 | 852 |
853 if (status < 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
854 retval(3) = msg; |
2669 | 855 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
856 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
857 FILE *ifile = fdopen (fid[0], "r"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
858 FILE *ofile = fdopen (fid[1], "w"); |
2075 | 859 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
860 std::string nm; |
4327 | 861 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
862 octave_stream is = octave_stdiostream::create (nm, ifile, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
863 std::ios::in); |
4327 | 864 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
865 octave_stream os = octave_stdiostream::create (nm, ofile, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
866 std::ios::out); |
2075 | 867 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
868 retval(2) = status; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
869 retval(1) = octave_stream_list::insert (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
870 retval(0) = octave_stream_list::insert (is); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
871 } |
2075 | 872 } |
873 else | |
5823 | 874 print_usage (); |
2075 | 875 |
876 return retval; | |
877 } | |
878 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
879 DEFUNX ("stat", Fstat, args, , |
3301 | 880 "-*- texinfo -*-\n\ |
10840 | 881 @deftypefn {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{file})\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
882 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} stat (@var{fid})\n\ |
3301 | 883 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{file})\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
884 @deftypefnx {Built-in Function} {[@var{info}, @var{err}, @var{msg}] =} lstat (@var{fid})\n\ |
12211
11faa69c4eaa
Add S_ISBLK and family of functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
885 Return a structure @var{info} containing the following information about\n\ |
11417
1a7b41db5432
Add additional calling form using file descriptor (fid) to docstring for stat.
Rik <octave@nomad.inbox5.com>
parents:
11152
diff
changeset
|
886 @var{file} or file identifier @var{fid}.\n\ |
3301 | 887 \n\ |
888 @table @code\n\ | |
889 @item dev\n\ | |
890 ID of device containing a directory entry for this file.\n\ | |
891 \n\ | |
892 @item ino\n\ | |
893 File number of the file.\n\ | |
894 \n\ | |
5476 | 895 @item mode\n\ |
9209
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
896 File mode, as an integer. Use the functions @w{@code{S_ISREG}},\n\ |
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
897 @w{@code{S_ISDIR}}, @w{@code{S_ISCHR}}, @w{@code{S_ISBLK}}, @w{@code{S_ISFIFO}},\n\ |
923c7cb7f13f
Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
898 @w{@code{S_ISLNK}}, or @w{@code{S_ISSOCK}} to extract information from this\n\ |
5476 | 899 value.\n\ |
900 \n\ | |
3301 | 901 @item modestr\n\ |
902 File mode, as a string of ten letters or dashes as would be returned by\n\ | |
903 @kbd{ls -l}.\n\ | |
904 \n\ | |
905 @item nlink\n\ | |
906 Number of links.\n\ | |
2075 | 907 \n\ |
3301 | 908 @item uid\n\ |
909 User ID of file's owner.\n\ | |
910 \n\ | |
911 @item gid\n\ | |
912 Group ID of file's group.\n\ | |
913 \n\ | |
914 @item rdev\n\ | |
915 ID of device for block or character special files.\n\ | |
916 \n\ | |
917 @item size\n\ | |
918 Size in bytes.\n\ | |
919 \n\ | |
920 @item atime\n\ | |
921 Time of last access in the same form as time values returned from\n\ | |
922 @code{time}. @xref{Timing Utilities}.\n\ | |
923 \n\ | |
924 @item mtime\n\ | |
925 Time of last modification in the same form as time values returned from\n\ | |
926 @code{time}. @xref{Timing Utilities}.\n\ | |
2075 | 927 \n\ |
3301 | 928 @item ctime\n\ |
929 Time of last file status change in the same form as time values\n\ | |
930 returned from @code{time}. @xref{Timing Utilities}.\n\ | |
931 \n\ | |
932 @item blksize\n\ | |
933 Size of blocks in the file.\n\ | |
934 \n\ | |
935 @item blocks\n\ | |
936 Number of blocks allocated for file.\n\ | |
937 @end table\n\ | |
938 \n\ | |
939 If the call is successful @var{err} is 0 and @var{msg} is an empty\n\ | |
940 string. If the file does not exist, or some other error occurs, @var{s}\n\ | |
941 is an empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\ | |
942 corresponding system error message.\n\ | |
943 \n\ | |
944 If @var{file} is a symbolic link, @code{stat} will return information\n\ | |
7001 | 945 about the actual file that is referenced by the link. Use @code{lstat}\n\ |
3301 | 946 if you want information about the symbolic link itself.\n\ |
947 \n\ | |
10840 | 948 For example:\n\ |
2075 | 949 \n\ |
3301 | 950 @example\n\ |
951 [s, err, msg] = stat (\"/vmlinuz\")\n\ | |
952 @result{} s =\n\ | |
953 @{\n\ | |
954 atime = 855399756\n\ | |
955 rdev = 0\n\ | |
956 ctime = 847219094\n\ | |
957 uid = 0\n\ | |
958 size = 389218\n\ | |
959 blksize = 4096\n\ | |
960 mtime = 847219094\n\ | |
961 gid = 6\n\ | |
962 nlink = 1\n\ | |
963 blocks = 768\n\ | |
5476 | 964 mode = -rw-r--r--\n\ |
3301 | 965 modestr = -rw-r--r--\n\ |
966 ino = 9316\n\ | |
967 dev = 2049\n\ | |
968 @}\n\ | |
969 @result{} err = 0\n\ | |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
12514
diff
changeset
|
970 @result{} msg =\n\ |
3301 | 971 @end example\n\ |
972 @end deftypefn") | |
2075 | 973 { |
2262 | 974 octave_value_list retval; |
2075 | 975 |
976 if (args.length () == 1) | |
977 { | |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
978 if (args(0).is_scalar_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
979 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
980 int fid = octave_stream_list::get_file_number (args(0)); |
2075 | 981 |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
982 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
983 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
984 file_fstat fs (fid); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
985 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
986 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
987 } |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
988 } |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
989 else |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
990 { |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
991 std::string fname = args(0).string_value (); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
992 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
993 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
994 { |
10336
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
995 file_stat fs (fname); |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
996 |
1603dfe72933
obsolete fstat, handle the functionality by stat
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
997 retval = mk_stat_result (fs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
998 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
999 } |
2075 | 1000 } |
1001 else | |
5823 | 1002 print_usage (); |
2075 | 1003 |
1004 return retval; | |
1005 } | |
1006 | |
5476 | 1007 DEFUNX ("S_ISREG", FS_ISREG, args, , |
1008 "-*- texinfo -*-\n\ | |
1009 @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\ | |
1010 Return true if @var{mode} corresponds to a regular file. The value\n\ | |
1011 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1012 @seealso{stat, lstat}\n\ | |
1013 @end deftypefn") | |
1014 { | |
1015 octave_value retval = false; | |
1016 | |
1017 if (args.length () == 1) | |
1018 { | |
1019 double mode = args(0).double_value (); | |
1020 | |
1021 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1022 retval = file_stat::is_reg (static_cast<mode_t> (mode)); |
5476 | 1023 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1024 error ("S_ISREG: invalid MODE value"); |
5476 | 1025 } |
1026 else | |
5823 | 1027 print_usage (); |
5476 | 1028 |
1029 return retval; | |
1030 } | |
1031 | |
1032 DEFUNX ("S_ISDIR", FS_ISDIR, args, , | |
1033 "-*- texinfo -*-\n\ | |
1034 @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\ | |
1035 Return true if @var{mode} corresponds to a directory. The value\n\ | |
1036 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1037 @seealso{stat, lstat}\n\ | |
1038 @end deftypefn") | |
1039 { | |
1040 octave_value retval = false; | |
1041 | |
1042 if (args.length () == 1) | |
1043 { | |
1044 double mode = args(0).double_value (); | |
1045 | |
1046 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1047 retval = file_stat::is_dir (static_cast<mode_t> (mode)); |
5476 | 1048 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1049 error ("S_ISDIR: invalid MODE value"); |
5476 | 1050 } |
1051 else | |
5823 | 1052 print_usage (); |
5476 | 1053 |
1054 return retval; | |
1055 } | |
1056 | |
1057 DEFUNX ("S_ISCHR", FS_ISCHR, args, , | |
1058 "-*- texinfo -*-\n\ | |
1059 @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\ | |
12212
f1ab2a12b4f4
Add S_ISSOCK function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
1060 Return true if @var{mode} corresponds to a character device. The value\n\ |
5476 | 1061 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
1062 @seealso{stat, lstat}\n\ | |
1063 @end deftypefn") | |
1064 { | |
1065 octave_value retval = false; | |
1066 | |
1067 if (args.length () == 1) | |
1068 { | |
1069 double mode = args(0).double_value (); | |
1070 | |
1071 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1072 retval = file_stat::is_chr (static_cast<mode_t> (mode)); |
5476 | 1073 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1074 error ("S_ISCHR: invalid MODE value"); |
5476 | 1075 } |
1076 else | |
5823 | 1077 print_usage (); |
5476 | 1078 |
1079 return retval; | |
1080 } | |
1081 | |
1082 DEFUNX ("S_ISBLK", FS_ISBLK, args, , | |
1083 "-*- texinfo -*-\n\ | |
1084 @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\ | |
1085 Return true if @var{mode} corresponds to a block device. The value\n\ | |
1086 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1087 @seealso{stat, lstat}\n\ | |
1088 @end deftypefn") | |
1089 { | |
1090 octave_value retval = false; | |
1091 | |
1092 if (args.length () == 1) | |
1093 { | |
1094 double mode = args(0).double_value (); | |
1095 | |
1096 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1097 retval = file_stat::is_blk (static_cast<mode_t> (mode)); |
5476 | 1098 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1099 error ("S_ISBLK: invalid MODE value"); |
5476 | 1100 } |
1101 else | |
5823 | 1102 print_usage (); |
5476 | 1103 |
1104 return retval; | |
1105 } | |
1106 | |
1107 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, , | |
1108 "-*- texinfo -*-\n\ | |
1109 @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\ | |
1110 Return true if @var{mode} corresponds to a fifo. The value\n\ | |
1111 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1112 @seealso{stat, lstat}\n\ | |
1113 @end deftypefn") | |
1114 { | |
1115 octave_value retval = false; | |
1116 | |
1117 if (args.length () == 1) | |
1118 { | |
1119 double mode = args(0).double_value (); | |
1120 | |
1121 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1122 retval = file_stat::is_fifo (static_cast<mode_t> (mode)); |
5476 | 1123 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1124 error ("S_ISFIFO: invalid MODE value"); |
5476 | 1125 } |
1126 else | |
5823 | 1127 print_usage (); |
5476 | 1128 |
1129 return retval; | |
1130 } | |
1131 | |
1132 DEFUNX ("S_ISLNK", FS_ISLNK, args, , | |
1133 "-*- texinfo -*-\n\ | |
1134 @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\ | |
1135 Return true if @var{mode} corresponds to a symbolic link. The value\n\ | |
1136 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ | |
1137 @seealso{stat, lstat}\n\ | |
1138 @end deftypefn") | |
1139 { | |
1140 octave_value retval = false; | |
1141 | |
1142 if (args.length () == 1) | |
1143 { | |
1144 double mode = args(0).double_value (); | |
1145 | |
1146 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1147 retval = file_stat::is_lnk (static_cast<mode_t> (mode)); |
5476 | 1148 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1149 error ("S_ISLNK: invalid MODE value"); |
5476 | 1150 } |
1151 else | |
5823 | 1152 print_usage (); |
5476 | 1153 |
1154 return retval; | |
1155 } | |
1156 | |
1157 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, , | |
1158 "-*- texinfo -*-\n\ | |
1159 @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\ | |
12212
f1ab2a12b4f4
Add S_ISSOCK function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
1160 Return true if @var{mode} corresponds to a socket. The value\n\ |
f1ab2a12b4f4
Add S_ISSOCK function to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12211
diff
changeset
|
1161 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\ |
5476 | 1162 @seealso{stat, lstat}\n\ |
1163 @end deftypefn") | |
1164 { | |
1165 octave_value retval = false; | |
1166 | |
1167 if (args.length () == 1) | |
1168 { | |
1169 double mode = args(0).double_value (); | |
1170 | |
1171 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1172 retval = file_stat::is_sock (static_cast<mode_t> (mode)); |
5476 | 1173 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1174 error ("S_ISSOCK: invalid MODE value"); |
5476 | 1175 } |
1176 else | |
5823 | 1177 print_usage (); |
5476 | 1178 |
1179 return retval; | |
1180 } | |
1181 | |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1182 DEFUN (gethostname, args, , |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1183 "-*- texinfo -*-\n\ |
12514
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1184 @deftypefn {Built-in Function} {} gethostname ()\n\ |
e5e66c389597
Add gethostname to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
1185 Return the hostname of the system where Octave is running.\n\ |
11006
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1186 @end deftypefn") |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1187 { |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1188 octave_value retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1189 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1190 if (args.length () == 0) |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1191 retval = octave_env::get_host_name (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1192 else |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1193 print_usage (); |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1194 |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1195 return retval; |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1196 } |
aca961a3f387
provide gethostname function
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
1197 |
5547 | 1198 DEFUN (uname, args, , |
1199 "-*- texinfo -*-\n\ | |
1200 @deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ | |
10840 | 1201 Return system information in the structure. For example:\n\ |
5547 | 1202 \n\ |
1203 @example\n\ | |
1204 @group\n\ | |
1205 uname ()\n\ | |
1206 @result{} @{\n\ | |
5656 | 1207 sysname = x86_64\n\ |
1208 nodename = segfault\n\ | |
1209 release = 2.6.15-1-amd64-k8-smp\n\ | |
1210 version = Linux\n\ | |
1211 machine = #2 SMP Thu Feb 23 04:57:49 UTC 2006\n\ | |
5547 | 1212 @}\n\ |
1213 @end group\n\ | |
1214 @end example\n\ | |
1215 \n\ | |
1216 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ | |
1217 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1218 system-dependent error message.\n\ | |
1219 @end deftypefn") | |
1220 { | |
1221 octave_value_list retval; | |
1222 | |
1223 if (args.length () == 0) | |
1224 { | |
1225 octave_uname sysinfo; | |
1226 | |
10762
d53eb6249892
use scalar map in some syscalls
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1227 octave_scalar_map m; |
5547 | 1228 |
1229 m.assign ("sysname", sysinfo.sysname ()); | |
1230 m.assign ("nodename", sysinfo.nodename ()); | |
1231 m.assign ("release", sysinfo.release ()); | |
1232 m.assign ("version", sysinfo.version ()); | |
1233 m.assign ("machine", sysinfo.machine ()); | |
1234 | |
1235 retval(2) = sysinfo.message (); | |
1236 retval(1) = sysinfo.error (); | |
1237 retval(0) = m; | |
1238 } | |
1239 else | |
5823 | 1240 print_usage (); |
5547 | 1241 |
1242 return retval; | |
1243 } | |
1244 | |
10197
4d433bd2d4dc
attempt to avoid trouble with gnulib #defines in a consistent way
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1245 DEFUNX ("unlink", Funlink, args, , |
3301 | 1246 "-*- texinfo -*-\n\ |
1247 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\ | |
1248 Delete the file named @var{file}.\n\ | |
2075 | 1249 \n\ |
3301 | 1250 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ |
1251 Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ | |
1252 system-dependent error message.\n\ | |
1253 @end deftypefn") | |
2075 | 1254 { |
2669 | 1255 octave_value_list retval; |
1256 | |
3523 | 1257 retval(1) = std::string (); |
4294 | 1258 retval(0) = -1; |
2075 | 1259 |
1260 int nargin = args.length (); | |
1261 | |
1262 if (nargin == 1) | |
1263 { | |
1264 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1265 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1266 std::string name = args(0).string_value (); |
2075 | 1267 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1268 std::string msg; |
2669 | 1269 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1270 int status = octave_unlink (name, msg); |
2669 | 1271 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1272 retval(1) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1273 retval(0) = status; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1274 } |
2075 | 1275 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1276 error ("unlink: FILE must be a string"); |
2075 | 1277 } |
1278 else | |
5823 | 1279 print_usage (); |
2075 | 1280 |
1281 return retval; | |
1282 } | |
1283 | |
10299
c992efc0c2fa
use DEFUNX instead of DEFUN for all functions in syscalls.cc
John W. Eaton <jwe@octave.org>
parents:
10259
diff
changeset
|
1284 DEFUNX ("waitpid", Fwaitpid, args, , |
3301 | 1285 "-*- texinfo -*-\n\ |
5453 | 1286 @deftypefn {Built-in Function} {[@var{pid}, @var{status}, @var{msg}] =} waitpid (@var{pid}, @var{options})\n\ |
3301 | 1287 Wait for process @var{pid} to terminate. The @var{pid} argument can be:\n\ |
2075 | 1288 \n\ |
3301 | 1289 @table @asis\n\ |
1290 @item @minus{}1\n\ | |
1291 Wait for any child process.\n\ | |
2075 | 1292 \n\ |
3301 | 1293 @item 0\n\ |
1294 Wait for any child process whose process group ID is equal to that of\n\ | |
1295 the Octave interpreter process.\n\ | |
2075 | 1296 \n\ |
3301 | 1297 @item > 0\n\ |
1298 Wait for termination of the child process with ID @var{pid}.\n\ | |
1299 @end table\n\ | |
1300 \n\ | |
5453 | 1301 The @var{options} argument can be a bitwise OR of zero or more of\n\ |
1302 the following constants:\n\ | |
2075 | 1303 \n\ |
5453 | 1304 @table @code\n\ |
3301 | 1305 @item 0\n\ |
1306 Wait until signal is received or a child process exits (this is the\n\ | |
1307 default if the @var{options} argument is missing).\n\ | |
1308 \n\ | |
5453 | 1309 @item WNOHANG\n\ |
3301 | 1310 Do not hang if status is not immediately available.\n\ |
2075 | 1311 \n\ |
5453 | 1312 @item WUNTRACED\n\ |
3301 | 1313 Report the status of any child processes that are stopped, and whose\n\ |
1314 status has not yet been reported since they stopped.\n\ | |
1315 \n\ | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1316 @item WCONTINUE\n\ |
5453 | 1317 Return if a stopped child has been resumed by delivery of @code{SIGCONT}.\n\ |
1318 This value may not be meaningful on all systems.\n\ | |
3301 | 1319 @end table\n\ |
1320 \n\ | |
1321 If the returned value of @var{pid} is greater than 0, it is the process\n\ | |
1322 ID of the child process that exited. If an error occurs, @var{pid} will\n\ | |
1323 be less than zero and @var{msg} will contain a system-dependent error\n\ | |
7001 | 1324 message. The value of @var{status} contains additional system-dependent\n\ |
5453 | 1325 information about the subprocess that exited.\n\ |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7924
diff
changeset
|
1326 @seealso{WCONTINUE, WCOREDUMP, WEXITSTATUS, WIFCONTINUED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED}\n\ |
3301 | 1327 @end deftypefn") |
2075 | 1328 { |
2669 | 1329 octave_value_list retval; |
1330 | |
5453 | 1331 retval(2) = std::string (); |
1332 retval(1) = 0; | |
4294 | 1333 retval(0) = -1; |
2075 | 1334 |
1335 int nargin = args.length (); | |
1336 | |
1337 if (nargin == 1 || nargin == 2) | |
1338 { | |
3202 | 1339 pid_t pid = args(0).int_value (true); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1340 |
2075 | 1341 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1342 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1343 int options = 0; |
2075 | 1344 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1345 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1346 options = args(1).int_value (true); |
2937 | 1347 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1348 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1349 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1350 std::string msg; |
2669 | 1351 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1352 int status = 0; |
5453 | 1353 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1354 pid_t result = octave_syscalls::waitpid (pid, &status, options, msg); |
3202 | 1355 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1356 retval(2) = msg; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1357 retval(1) = status; |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
1358 retval(0) = result; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1359 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1360 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1361 error ("waitpid: OPTIONS must be an integer"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1362 } |
3202 | 1363 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1364 error ("waitpid: PID must be an integer value"); |
2075 | 1365 } |
1366 else | |
5823 | 1367 print_usage (); |
2075 | 1368 |
1369 return retval; | |
1370 } | |
1371 | |
5453 | 1372 DEFUNX ("WIFEXITED", FWIFEXITED, args, , |
1373 "-*- texinfo -*-\n\ | |
1374 @deftypefn {Built-in Function} {} WIFEXITED (@var{status})\n\ | |
1375 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1376 child terminated normally.\n\ | |
1377 @seealso{waitpid, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
5646 | 1378 @end deftypefn") |
5453 | 1379 { |
1380 octave_value retval = 0.0; | |
1381 | |
1382 #if defined (WIFEXITED) | |
1383 if (args.length () == 1) | |
1384 { | |
1385 int status = args(0).int_value (); | |
1386 | |
1387 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1388 retval = WIFEXITED (status); |
5453 | 1389 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1390 error ("WIFEXITED: STATUS must be an integer"); |
5453 | 1391 } |
1392 #else | |
11546
1b7bb90e670a
syscalls.cc: missing semicolons
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1393 warning ("WIFEXITED always returns false in this version of Octave"); |
5453 | 1394 #endif |
1395 | |
1396 return retval; | |
1397 } | |
1398 | |
1399 DEFUNX ("WEXITSTATUS", FWEXITSTATUS, args, , | |
1400 "-*- texinfo -*-\n\ | |
1401 @deftypefn {Built-in Function} {} WEXITSTATUS (@var{status})\n\ | |
1402 Given @var{status} from a call to @code{waitpid}, return the exit\n\ | |
1403 status of the child. This function should only be employed if\n\ | |
1404 @code{WIFEXITED} returned true.\n\ | |
1405 @seealso{waitpid, WIFEXITED, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1406 @end deftypefn") | |
1407 { | |
1408 octave_value retval = 0.0; | |
1409 | |
1410 #if defined (WEXITSTATUS) | |
1411 if (args.length () == 1) | |
1412 { | |
1413 int status = args(0).int_value (); | |
1414 | |
1415 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1416 retval = WEXITSTATUS (status); |
5453 | 1417 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1418 error ("WEXITSTATUS: STATUS must be an integer"); |
5453 | 1419 } |
1420 #else | |
11546
1b7bb90e670a
syscalls.cc: missing semicolons
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1421 warning ("WEXITSTATUS always returns false in this version of Octave"); |
5453 | 1422 #endif |
1423 | |
1424 return retval; | |
1425 } | |
1426 | |
1427 DEFUNX ("WIFSIGNALED", FWIFSIGNALED, args, , | |
1428 "-*- texinfo -*-\n\ | |
1429 @deftypefn {Built-in Function} {} WIFSIGNALED (@var{status})\n\ | |
1430 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1431 child process was terminated by a signal.\n\ | |
1432 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1433 @end deftypefn") | |
1434 { | |
1435 octave_value retval = 0.0; | |
1436 | |
1437 #if defined (WIFSIGNALED) | |
1438 if (args.length () == 1) | |
1439 { | |
1440 int status = args(0).int_value (); | |
1441 | |
1442 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1443 retval = WIFSIGNALED (status); |
5453 | 1444 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1445 error ("WIFSIGNALED: STATUS must be an integer"); |
5453 | 1446 } |
1447 #else | |
5455 | 1448 warning ("WIFSIGNALED always returns false in this version of Octave"); |
5453 | 1449 #endif |
1450 | |
1451 return retval; | |
1452 } | |
1453 | |
1454 DEFUNX ("WTERMSIG", FWTERMSIG, args, , | |
1455 "-*- texinfo -*-\n\ | |
1456 @deftypefn {Built-in Function} {} WTERMSIG (@var{status})\n\ | |
1457 Given @var{status} from a call to @code{waitpid}, return the number of\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1458 the signal that caused the child process to terminate. This function\n\ |
5453 | 1459 should only be employed if @code{WIFSIGNALED} returned true.\n\ |
1460 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WCOREDUMP, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1461 @end deftypefn") | |
1462 { | |
1463 octave_value retval = 0.0; | |
1464 | |
1465 #if defined (WTERMSIG) | |
1466 if (args.length () == 1) | |
1467 { | |
1468 int status = args(0).int_value (); | |
1469 | |
1470 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1471 retval = WTERMSIG (status); |
5453 | 1472 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1473 error ("WTERMSIG: STATUS must be an integer"); |
5453 | 1474 } |
1475 #else | |
5455 | 1476 warning ("WTERMSIG always returns false in this version of Octave"); |
5453 | 1477 #endif |
1478 | |
1479 return retval; | |
1480 } | |
1481 | |
1482 DEFUNX ("WCOREDUMP", FWCOREDUMP, args, , | |
1483 "-*- texinfo -*-\n\ | |
1484 @deftypefn {Built-in Function} {} WCOREDUMP (@var{status})\n\ | |
1485 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1486 child produced a core dump. This function should only be employed if\n\ | |
1487 @code{WIFSIGNALED} returned true. The macro used to implement this\n\ | |
1488 function is not specified in POSIX.1-2001 and is not available on some\n\ | |
1489 Unix implementations (e.g., AIX, SunOS).\n\ | |
1490 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, WIFCONTINUED}\n\ | |
1491 @end deftypefn") | |
1492 { | |
1493 octave_value retval = 0.0; | |
1494 | |
1495 #if defined (WCOREDUMP) | |
1496 if (args.length () == 1) | |
1497 { | |
1498 int status = args(0).int_value (); | |
1499 | |
1500 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1501 retval = WCOREDUMP (status); |
5453 | 1502 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1503 error ("WCOREDUMP: STATUS must be an integer"); |
5453 | 1504 } |
1505 #else | |
5455 | 1506 warning ("WCOREDUMP always returns false in this version of Octave"); |
5453 | 1507 #endif |
1508 | |
1509 return retval; | |
1510 } | |
1511 | |
1512 DEFUNX ("WIFSTOPPED", FWIFSTOPPED, args, , | |
1513 "-*- texinfo -*-\n\ | |
1514 @deftypefn {Built-in Function} {} WIFSTOPPED (@var{status})\n\ | |
1515 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1516 child process was stopped by delivery of a signal; this is only\n\ | |
1517 possible if the call was done using @code{WUNTRACED} or when the child\n\ | |
1518 is being traced (see ptrace(2)).\n\ | |
1519 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WSTOPSIG, WIFCONTINUED}\n\ | |
1520 @end deftypefn") | |
1521 { | |
1522 octave_value retval = 0.0; | |
1523 | |
1524 #if defined (WIFSTOPPED) | |
1525 if (args.length () == 1) | |
1526 { | |
1527 int status = args(0).int_value (); | |
1528 | |
1529 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1530 retval = WIFSTOPPED (status); |
5453 | 1531 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1532 error ("WIFSTOPPED: STATUS must be an integer"); |
5453 | 1533 } |
1534 #else | |
5455 | 1535 warning ("WIFSTOPPED always returns false in this version of Octave"); |
5453 | 1536 #endif |
1537 | |
1538 return retval; | |
1539 } | |
1540 | |
1541 DEFUNX ("WSTOPSIG", FWSTOPSIG, args, , | |
1542 "-*- texinfo -*-\n\ | |
1543 @deftypefn {Built-in Function} {} WSTOPSIG (@var{status})\n\ | |
1544 Given @var{status} from a call to @code{waitpid}, return the number of\n\ | |
1545 the signal which caused the child to stop. This function should only\n\ | |
1546 be employed if @code{WIFSTOPPED} returned true.\n\ | |
1547 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WIFCONTINUED}\n\ | |
1548 @end deftypefn") | |
1549 { | |
1550 octave_value retval = 0.0; | |
1551 | |
1552 #if defined (WSTOPSIG) | |
1553 if (args.length () == 1) | |
1554 { | |
1555 int status = args(0).int_value (); | |
1556 | |
1557 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1558 retval = WSTOPSIG (status); |
5453 | 1559 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1560 error ("WSTOPSIG: STATUS must be an integer"); |
5453 | 1561 } |
1562 #else | |
5455 | 1563 warning ("WSTOPSIG always returns false in this version of Octave"); |
5453 | 1564 #endif |
1565 | |
1566 return retval; | |
1567 } | |
1568 | |
1569 DEFUNX ("WIFCONTINUED", FWIFCONTINUED, args, , | |
1570 "-*- texinfo -*-\n\ | |
1571 @deftypefn {Built-in Function} {} WIFCONTINUED (@var{status})\n\ | |
1572 Given @var{status} from a call to @code{waitpid}, return true if the\n\ | |
1573 child process was resumed by delivery of @code{SIGCONT}.\n\ | |
1574 @seealso{waitpid, WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WCOREDUMP, WIFSTOPPED, WSTOPSIG}\n\ | |
1575 @end deftypefn") | |
1576 { | |
1577 octave_value retval = 0.0; | |
1578 | |
1579 #if defined (WIFCONTINUED) | |
1580 if (args.length () == 1) | |
1581 { | |
1582 int status = args(0).int_value (); | |
1583 | |
1584 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1585 retval = WIFCONTINUED (status); |
5453 | 1586 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1587 error ("WIFCONTINUED: STATUS must be an integer"); |
5453 | 1588 } |
1589 #else | |
5455 | 1590 warning ("WIFCONTINUED always returns false in this version of Octave"); |
5453 | 1591 #endif |
1592 | |
1593 return retval; | |
1594 } | |
1595 | |
10249
14eba566f9f0
use DEFUNX instead of DEFUN for canonicalize_file_name
John W. Eaton <jwe@octave.org>
parents:
10197
diff
changeset
|
1596 DEFUNX ("canonicalize_file_name", Fcanonicalize_file_name, args, , |
5138 | 1597 "-*- texinfo -*-\n\ |
1598 @deftypefn {Built-in Function} {[@var{cname}, @var{status}, @var{msg}]} canonicalize_file_name (@var{name})\n\ | |
1599 Return the canonical name of file @var{name}.\n\ | |
1600 @end deftypefn") | |
1601 { | |
1602 octave_value_list retval; | |
1603 | |
1604 if (args.length () == 1) | |
1605 { | |
1606 std::string name = args(0).string_value (); | |
1607 | |
1608 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1609 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1610 std::string msg; |
5138 | 1611 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1612 std::string result = octave_canonicalize_file_name (name, msg); |
5138 | 1613 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1614 retval(2) = msg; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1615 retval(1) = msg.empty () ? 0 : -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1616 retval(0) = result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10299
diff
changeset
|
1617 } |
5138 | 1618 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12212
diff
changeset
|
1619 error ("canonicalize_file_name: NAME must be a character string"); |
5138 | 1620 } |
1621 else | |
5823 | 1622 print_usage (); |
5138 | 1623 |
1624 return retval; | |
1625 } | |
1626 | |
5749 | 1627 static octave_value |
7924 | 1628 const_value (const octave_value_list& args, int val) |
5749 | 1629 { |
1630 octave_value retval; | |
1631 | |
1632 int nargin = args.length (); | |
1633 | |
1634 if (nargin == 0) | |
1635 retval = val; | |
1636 else | |
5823 | 1637 print_usage (); |
5749 | 1638 |
1639 return retval; | |
1640 } | |
1641 | |
2075 | 1642 #if !defined (O_NONBLOCK) && defined (O_NDELAY) |
1643 #define O_NONBLOCK O_NDELAY | |
1644 #endif | |
1645 | |
5749 | 1646 DEFUNX ("F_DUPFD", FF_DUPFD, args, , |
1647 "-*- texinfo -*-\n\ | |
1648 @deftypefn {Built-in Function} {} F_DUPFD ()\n\ | |
1649 Return the value required to request that @code{fcntl} return a\n\ | |
1650 duplicate file descriptor.\n\ | |
1651 @seealso{fcntl, F_GETFD, F_GETFL, F_SETFD, F_SETFL}\n\ | |
1652 @end deftypefn") | |
2075 | 1653 { |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1654 #if defined (F_DUPFD) |
7924 | 1655 return const_value (args, F_DUPFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1656 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1657 error ("F_DUPFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1658 return octave_value (); |
2075 | 1659 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1660 } |
2075 | 1661 |
5749 | 1662 DEFUNX ("F_GETFD", FF_GETFD, args, , |
1663 "-*- texinfo -*-\n\ | |
1664 @deftypefn {Built-in Function} {} F_GETFD ()\n\ | |
1665 Return the value required to request that @code{fcntl} to return the\n\ | |
1666 file descriptor flags.\n\ | |
5333 | 1667 @seealso{fcntl, F_DUPFD, F_GETFL, F_SETFD, F_SETFL}\n\ |
5749 | 1668 @end deftypefn") |
1669 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1670 #if defined (F_GETFD) |
7924 | 1671 return const_value (args, F_GETFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1672 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1673 error ("F_GETFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1674 return octave_value (); |
2075 | 1675 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1676 } |
2075 | 1677 |
5749 | 1678 DEFUNX ("F_GETFL", FF_GETFL, args, , |
1679 "-*- texinfo -*-\n\ | |
1680 @deftypefn {Built-in Function} {} F_GETFL ()\n\ | |
1681 Return the value required to request that @code{fcntl} to return the\n\ | |
1682 file status flags.\n\ | |
5333 | 1683 @seealso{fcntl, F_DUPFD, F_GETFD, F_SETFD, F_SETFL}\n\ |
5749 | 1684 @end deftypefn") |
1685 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1686 #if defined (F_GETFL) |
7924 | 1687 return const_value (args, F_GETFL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1688 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1689 error ("F_GETFL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1690 return octave_value (); |
2075 | 1691 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1692 } |
2075 | 1693 |
5749 | 1694 DEFUNX ("F_SETFD", FF_SETFD, args, , |
1695 "-*- texinfo -*-\n\ | |
1696 @deftypefn {Built-in Function} {} F_SETFD ()\n\ | |
1697 Return the value required to request that @code{fcntl} to set the file\n\ | |
1698 descriptor flags.\n\ | |
5333 | 1699 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFL}\n\ |
5749 | 1700 @end deftypefn") |
1701 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1702 #if defined (F_SETFD) |
7924 | 1703 return const_value (args, F_SETFD); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1704 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1705 error ("F_SETFD: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1706 return octave_value (); |
2075 | 1707 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1708 } |
2075 | 1709 |
5749 | 1710 DEFUNX ("F_SETFL", FF_SETFL, args, , |
1711 "-*- texinfo -*-\n\ | |
1712 @deftypefn {Built-in Function} {} F_SETFL ()\n\ | |
1713 Return the value required to request that @code{fcntl} to set the file\n\ | |
1714 status flags.\n\ | |
5333 | 1715 @seealso{fcntl, F_DUPFD, F_GETFD, F_GETFL, F_SETFD}\n\ |
5749 | 1716 @end deftypefn") |
1717 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1718 #if defined (F_SETFL) |
7924 | 1719 return const_value (args, F_SETFL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1720 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1721 error ("F_SETFL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1722 return octave_value (); |
2075 | 1723 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1724 } |
2075 | 1725 |
5749 | 1726 DEFUNX ("O_APPEND", FO_APPEND, args, , |
1727 "-*- texinfo -*-\n\ | |
1728 @deftypefn {Built-in Function} {} O_APPEND ()\n\ | |
1729 Return the numerical value of the file status flag that may be\n\ | |
1730 returned by @code{fcntl} to indicate each write operation appends,\n\ | |
11152
39ae406df598
Improve docstrings for functions found in undocumented list.
Rik <octave@nomad.inbox5.com>
parents:
11006
diff
changeset
|
1731 or that may be passed to @code{fcntl} to set the write mode to append.\n\ |
5333 | 1732 @seealso{fcntl, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1733 @end deftypefn") |
1734 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1735 #if defined (O_APPEND) |
7924 | 1736 return const_value (args, O_APPEND); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1737 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1738 error ("O_APPEND: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1739 return octave_value (); |
2075 | 1740 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1741 } |
2075 | 1742 |
5749 | 1743 DEFUNX ("O_ASYNC", FO_ASYNC, args, , |
1744 "-*- texinfo -*-\n\ | |
1745 @deftypefn {Built-in Function} {} O_ASYNC ()\n\ | |
1746 Return the numerical value of the file status flag that may be\n\ | |
1747 returned by @code{fcntl} to indicate asynchronous I/O.\n\ | |
5333 | 1748 @seealso{fcntl, O_APPEND, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1749 @end deftypefn") |
1750 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1751 #if defined (O_ASYNC) |
7924 | 1752 return const_value (args, O_ASYNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1753 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1754 error ("O_ASYNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1755 return octave_value (); |
2669 | 1756 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1757 } |
2669 | 1758 |
5749 | 1759 DEFUNX ("O_CREAT", FO_CREAT, args, , |
1760 "-*- texinfo -*-\n\ | |
1761 @deftypefn {Built-in Function} {} O_CREAT ()\n\ | |
1762 Return the numerical value of the file status flag that may be\n\ | |
1763 returned by @code{fcntl} to indicate that a file should be\n\ | |
1764 created if it does not exist.\n\ | |
5333 | 1765 @seealso{fcntl, O_APPEND, O_ASYNC, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1766 @end deftypefn") |
1767 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1768 #if defined (O_CREAT) |
7924 | 1769 return const_value (args, O_CREAT); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1770 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1771 error ("O_CREAT: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1772 return octave_value (); |
2075 | 1773 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1774 } |
2075 | 1775 |
5749 | 1776 DEFUNX ("O_EXCL", FO_EXCL, args, , |
1777 "-*- texinfo -*-\n\ | |
1778 @deftypefn {Built-in Function} {} O_EXCL ()\n\ | |
1779 Return the numerical value of the file status flag that may be\n\ | |
1780 returned by @code{fcntl} to indicate that file locking is used.\n\ | |
5333 | 1781 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1782 @end deftypefn") |
1783 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1784 #if defined (O_EXCL) |
7924 | 1785 return const_value (args, O_EXCL); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1786 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1787 error ("O_EXCL: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1788 return octave_value (); |
2075 | 1789 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1790 } |
2075 | 1791 |
5749 | 1792 DEFUNX ("O_NONBLOCK", FO_NONBLOCK, args, , |
1793 "-*- texinfo -*-\n\ | |
1794 @deftypefn {Built-in Function} {} O_NONBLOCK ()\n\ | |
1795 Return the numerical value of the file status flag that may be\n\ | |
1796 returned by @code{fcntl} to indicate that non-blocking I/O is in use,\n\ | |
1797 or that may be passsed to @code{fcntl} to set non-blocking I/O.\n\ | |
5333 | 1798 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1799 @end deftypefn") |
1800 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1801 #if defined (O_NONBLOCK) |
7924 | 1802 return const_value (args, O_NONBLOCK); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1803 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1804 error ("O_NONBLOCK: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1805 return octave_value (); |
2075 | 1806 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1807 } |
2075 | 1808 |
5749 | 1809 DEFUNX ("O_RDONLY", FO_RDONLY, args, , |
1810 "-*- texinfo -*-\n\ | |
1811 @deftypefn {Built-in Function} {} O_RDONLY ()\n\ | |
1812 Return the numerical value of the file status flag that may be\n\ | |
1813 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1814 reading only.\n\ | |
5333 | 1815 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1816 @end deftypefn") |
1817 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1818 #if defined (O_RDONLY) |
7924 | 1819 return const_value (args, O_RDONLY); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1820 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1821 error ("O_RDONLY: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1822 return octave_value (); |
2075 | 1823 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1824 } |
2075 | 1825 |
5749 | 1826 DEFUNX ("O_RDWR", FO_RDWR, args, , |
1827 "-*- texinfo -*-\n\ | |
1828 @deftypefn {Built-in Function} {} O_RDWR ()\n\ | |
1829 Return the numerical value of the file status flag that may be\n\ | |
1830 returned by @code{fcntl} to indicate that a file is open for both\n\ | |
1831 reading and writing.\n\ | |
5333 | 1832 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_SYNC, O_TRUNC, O_WRONLY}\n\ |
5749 | 1833 @end deftypefn") |
1834 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1835 #if defined (O_RDWR) |
7924 | 1836 return const_value (args, O_RDWR); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1837 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1838 error ("O_RDWR: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1839 return octave_value (); |
2075 | 1840 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1841 } |
2075 | 1842 |
5749 | 1843 DEFUNX ("O_SYNC", FO_SYNC, args, , |
1844 "-*- texinfo -*-\n\ | |
1845 @deftypefn {Built-in Function} {} O_SYNC ()\n\ | |
1846 Return the numerical value of the file status flag that may be\n\ | |
1847 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1848 synchronous I/O.\n\ | |
5333 | 1849 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}\n\ |
5749 | 1850 @end deftypefn") |
1851 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1852 #if defined (O_SYNC) |
7924 | 1853 return const_value (args, O_SYNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1854 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1855 error ("O_SYNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1856 return octave_value (); |
2669 | 1857 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1858 } |
2669 | 1859 |
5749 | 1860 DEFUNX ("O_TRUNC", FO_TRUNC, args, , |
1861 "-*- texinfo -*-\n\ | |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11546
diff
changeset
|
1862 @deftypefn {Built-in Function} O_TRUNC ()\n\ |
5749 | 1863 Return the numerical value of the file status flag that may be\n\ |
1864 returned by @code{fcntl} to indicate that if file exists, it should\n\ | |
1865 be truncated when writing.\n\ | |
5333 | 1866 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_WRONLY}\n\ |
5749 | 1867 @end deftypefn") |
1868 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1869 #if defined (O_TRUNC) |
7924 | 1870 return const_value (args, O_TRUNC); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1871 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1872 error ("O_TRUNC: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1873 return octave_value (); |
2075 | 1874 #endif |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1875 } |
2075 | 1876 |
5749 | 1877 DEFUNX ("O_WRONLY", FO_WRONLY, args, , |
1878 "-*- texinfo -*-\n\ | |
1879 @deftypefn {Built-in Function} {} O_WRONLY ()\n\ | |
1880 Return the numerical value of the file status flag that may be\n\ | |
1881 returned by @code{fcntl} to indicate that a file is open for\n\ | |
1882 writing only.\n\ | |
5333 | 1883 @seealso{fcntl, O_APPEND, O_ASYNC, O_CREAT, O_EXCL, O_NONBLOCK, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC}\n\ |
5749 | 1884 @end deftypefn") |
1885 { | |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1886 #if defined (O_WRONLY) |
7924 | 1887 return const_value (args, O_WRONLY); |
14111
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1888 #else |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1889 error ("O_WRONLY: not available on this system"); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1890 return octave_value (); |
c5222658dc3c
doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
1891 #endif |
5749 | 1892 } |
3446 | 1893 |
5453 | 1894 #if !defined (WNOHANG) |
1895 #define WNOHANG 0 | |
1896 #endif | |
1897 | |
5749 | 1898 DEFUNX ("WNOHANG", FWNOHANG, args, , |
1899 "-*- texinfo -*-\n\ | |
1900 @deftypefn {Built-in Function} {} WNOHANG ()\n\ | |
1901 Return the numerical value of the option argument that may be\n\ | |
1902 passed to @code{waitpid} to indicate that it should return its\n\ | |
1903 status immediately instead of waiting for a process to exit.\n\ | |
5453 | 1904 @seealso{waitpid, WUNTRACED, WCONTINUE}\n\ |
5749 | 1905 @end deftypefn") |
1906 { | |
7924 | 1907 return const_value (args, WNOHANG); |
5749 | 1908 } |
5453 | 1909 |
1910 #if !defined (WUNTRACED) | |
1911 #define WUNTRACED 0 | |
1912 #endif | |
1913 | |
5749 | 1914 DEFUNX ("WUNTRACED", FWUNTRACED, args, , |
1915 "-*- texinfo -*-\n\ | |
1916 @deftypefn {Built-in Function} {} WUNTRACED ()\n\ | |
1917 Return the numerical value of the option argument that may be\n\ | |
1918 passed to @code{waitpid} to indicate that it should also return\n\ | |
1919 if the child process has stopped but is not traced via the\n\ | |
1920 @code{ptrace} system call\n\ | |
5453 | 1921 @seealso{waitpid, WNOHANG, WCONTINUE}\n\ |
5749 | 1922 @end deftypefn") |
1923 { | |
7924 | 1924 return const_value (args, WUNTRACED); |
5749 | 1925 } |
5453 | 1926 |
1927 #if !defined (WCONTINUE) | |
1928 #define WCONTINUE 0 | |
1929 #endif | |
1930 | |
5749 | 1931 DEFUNX ("WCONTINUE", FWCONTINUE, args, , |
1932 "-*- texinfo -*-\n\ | |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9564
diff
changeset
|
1933 @deftypefn {Built-in Function} {} WCONTINUE ()\n\ |
5749 | 1934 Return the numerical value of the option argument that may be\n\ |
1935 passed to @code{waitpid} to indicate that it should also return\n\ | |
1936 if a stopped child has been resumed by delivery of a @code{SIGCONT}\n\ | |
1937 signal.\n\ | |
5453 | 1938 @seealso{waitpid, WNOHANG, WUNTRACED}\n\ |
5749 | 1939 @end deftypefn") |
1940 { | |
7924 | 1941 return const_value (args, WCONTINUE); |
2075 | 1942 } |