Mercurial > hg > octave-kai
changeset 5547:8b0b36c2dc0c
[project @ 2005-11-29 17:41:33 by jwe]
author | jwe |
---|---|
date | Tue, 29 Nov 2005 17:41:33 +0000 |
parents | 3ebf0e35156c |
children | 5cc01ba4c052 |
files | ChangeLog configure.in liboctave/ChangeLog liboctave/Makefile.in liboctave/oct-uname.cc liboctave/oct-uname.h src/ChangeLog src/syscalls.cc |
diffstat | 8 files changed, 230 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-11-28 John W. Eaton <jwe@octave.org> + + * configure.in: Check for uname. + 2005-11-21 John W. Eaton <jwe@octave.org> * examples/Makefile.in (DISTFILES): Don't include octave.desktop here.
--- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ EXTERN_CXXFLAGS="$CXXFLAGS" AC_INIT -AC_REVISION($Revision: 1.492 $) +AC_REVISION($Revision: 1.493 $) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1224,8 +1224,8 @@ readlink rename resolvepath rindex rmdir round select setgrent \ setpwent setvbuf sigaction siglongjmp sigpending sigprocmask \ sigsuspend stat strcasecmp strdup strerror strftime stricmp \ - strncasecmp strnicmp strptime symlink tempnam umask unlink usleep \ - vfprintf vsprintf vsnprintf waitpid) + strncasecmp strnicmp strptime symlink tempnam umask uname unlink \ + usleep vfprintf vsprintf vsnprintf waitpid) OCTAVE_SMART_PUTENV
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2005-11-29 John W. Eaton <jwe@octave.org> + + * oct-uname.h, oct-uname.cc: New files. + * Makefile.in: Add them to the appropriate lists. + 2005-11-11 John W. Eaton <jwe@octave.org> * Array.cc (Array<T>::indexN): Simplify.
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -66,7 +66,8 @@ oct-env.h oct-fftw.h oct-getopt.h oct-group.h oct-inttypes.h \ oct-passwd.h oct-rand.h oct-rl-edit.h oct-rl-hist.h \ oct-shlib.h oct-sort.h oct-spparms.h oct-syscalls.h \ - oct-sparse.h oct-time.h oct-types.h pathlen.h pathsearch.h \ + oct-sparse.h oct-time.h oct-types.h oct-uname.h \ + pathlen.h pathsearch.h \ prog-args.h so-array.h sparse-sort.h statdefs.h str-vec.h \ sparse-util.h sun-utils.h sysdir.h systime.h syswait.h \ $(OPTS_INC) \ @@ -113,8 +114,8 @@ lo-ieee.cc lo-mappers.cc lo-specfun.cc lo-sysdep.cc \ lo-utils.cc mach-info.cc oct-alloc.cc oct-env.cc \ oct-fftw.cc oct-group.cc oct-passwd.cc oct-rand.cc oct-shlib.cc \ - oct-spparms.cc oct-syscalls.cc oct-time.cc prog-args.cc \ - so-array.cc sparse-sort.cc sparse-util.cc str-vec.cc \ + oct-spparms.cc oct-syscalls.cc oct-time.cc oct-uname.cc \ + prog-args.cc so-array.cc sparse-sort.cc sparse-util.cc str-vec.cc \ $(TEMPLATE_SRC) \ $(TI_SRC) \ $(MATRIX_SRC) \
new file mode 100644 --- /dev/null +++ b/liboctave/oct-uname.cc @@ -0,0 +1,64 @@ +/* + +Copyright (C) 2005 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <cerrno> + +#ifdef HAVE_SYS_UTSNAME_H +#include <sys/utsname.h> +#endif + +#include "oct-uname.h" + +void +octave_uname::init (void) +{ +#if defined (HAVE_UNAME) && defined (HAVE_SYS_UTSNAME_H) + struct utsname unm; + + err = ::uname (&unm); + + if (err < 0) + { + using namespace std; + msg = ::strerror (errno); + } + else + { + utsname_sysname = unm.sysname; + utsname_nodename = unm.nodename; + utsname_release = unm.release; + utsname_version = unm.version; + utsname_machine = unm.machine; + } +#endif +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/
new file mode 100644 --- /dev/null +++ b/liboctave/oct-uname.h @@ -0,0 +1,98 @@ +/* + +Copyright (C) 2005 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. + +*/ + +#if !defined (octave_uame_h) +#define octave_uname_h 1 + +#include <string> + +class +octave_uname +{ +public: + + octave_uname (void) + : utsname_sysname ("unknown"), utsname_nodename ("unknown"), + utsname_release ("unknown"), utsname_version ("unknown"), + utsname_machine ("unknown"), + msg ("uname not supported on this system"), err (-1) + { init (); } + + octave_uname (const octave_uname& unm) + : utsname_sysname (unm.utsname_sysname), + utsname_nodename (unm.utsname_nodename), + utsname_release (unm.utsname_release), + utsname_version (unm.utsname_version), + utsname_machine (unm.utsname_machine), + msg (unm.msg), err (unm.err) + { } + + octave_uname& operator = (const octave_uname& unm) + { + if (this != &unm) + { + utsname_sysname = unm.utsname_sysname; + utsname_nodename = unm.utsname_nodename; + utsname_release = unm.utsname_release; + utsname_version = unm.utsname_version; + utsname_machine = unm.utsname_machine; + + msg = unm.msg; + err = unm.err; + } + + return *this; + } + + ~octave_uname (void) { } + + std::string sysname (void) const { return utsname_sysname; } + std::string nodename (void) const { return utsname_nodename; } + std::string release (void) const { return utsname_release; } + std::string version (void) const { return utsname_version; } + std::string machine (void) const { return utsname_machine; } + + std::string message (void) const { return msg; } + int error (void) const { return err; } + +private: + + std::string utsname_sysname; + std::string utsname_nodename; + std::string utsname_release; + std::string utsname_version; + std::string utsname_machine; + + std::string msg; + int err; + + void init (void); +}; + +#endif + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-11-28 John W. Eaton <jwe@octave.org> + + * syscalls.cc (Funame): New function. + 2005-11-21 John W. Eaton <jwe@octave.org> * pr-output.cc (pr_int): Fix thinko in byte-swapping for bit format.
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -47,6 +47,7 @@ #include "file-ops.h" #include "file-stat.h" #include "oct-syscalls.h" +#include "oct-uname.h" #include "defun.h" #include "error.h" @@ -996,6 +997,53 @@ return retval; } +DEFUN (uname, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ +Return system information in the structure. For example,\n\ +\n\ +@example\n\ +@group\n\ +uname ()\n\ + @result{} @{\n\ + sysname = \n\ + nodename = \n\ + release = \n\ + version = \n\ + machine = \n\ + @}\n\ +@end group\n\ +@end example\n\ +\n\ +If successful, @var{err} is 0 and @var{msg} is an empty string.\n\ +Otherwise, @var{err} is nonzero and @var{msg} contains a\n\ +system-dependent error message.\n\ +@end deftypefn") +{ + octave_value_list retval; + + if (args.length () == 0) + { + octave_uname sysinfo; + + Octave_map m; + + m.assign ("sysname", sysinfo.sysname ()); + m.assign ("nodename", sysinfo.nodename ()); + m.assign ("release", sysinfo.release ()); + m.assign ("version", sysinfo.version ()); + m.assign ("machine", sysinfo.machine ()); + + retval(2) = sysinfo.message (); + retval(1) = sysinfo.error (); + retval(0) = m; + } + else + print_usage ("uname"); + + return retval; +} + DEFUN (unlink, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\