# HG changeset patch # User jwe # Date 1133286093 0 # Node ID 8b0b36c2dc0cc28fc0dc3ecf48e8d9d1cfba4981 # Parent 3ebf0e35156c860c8e6f925fc000482929df1c42 [project @ 2005-11-29 17:41:33 by jwe] diff -r 3ebf0e35156c -r 8b0b36c2dc0c ChangeLog --- a/ChangeLog Tue Nov 29 17:31:04 2005 +0000 +++ b/ChangeLog Tue Nov 29 17:41:33 2005 +0000 @@ -1,3 +1,7 @@ +2005-11-28 John W. Eaton + + * configure.in: Check for uname. + 2005-11-21 John W. Eaton * examples/Makefile.in (DISTFILES): Don't include octave.desktop here. diff -r 3ebf0e35156c -r 8b0b36c2dc0c configure.in --- a/configure.in Tue Nov 29 17:31:04 2005 +0000 +++ b/configure.in Tue Nov 29 17:41:33 2005 +0000 @@ -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 diff -r 3ebf0e35156c -r 8b0b36c2dc0c liboctave/ChangeLog --- a/liboctave/ChangeLog Tue Nov 29 17:31:04 2005 +0000 +++ b/liboctave/ChangeLog Tue Nov 29 17:41:33 2005 +0000 @@ -1,3 +1,8 @@ +2005-11-29 John W. Eaton + + * oct-uname.h, oct-uname.cc: New files. + * Makefile.in: Add them to the appropriate lists. + 2005-11-11 John W. Eaton * Array.cc (Array::indexN): Simplify. diff -r 3ebf0e35156c -r 8b0b36c2dc0c liboctave/Makefile.in --- a/liboctave/Makefile.in Tue Nov 29 17:31:04 2005 +0000 +++ b/liboctave/Makefile.in Tue Nov 29 17:41:33 2005 +0000 @@ -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) \ diff -r 3ebf0e35156c -r 8b0b36c2dc0c liboctave/oct-uname.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/oct-uname.cc Tue Nov 29 17:41:33 2005 +0000 @@ -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 +#endif + +#include + +#ifdef HAVE_SYS_UTSNAME_H +#include +#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: *** +*/ diff -r 3ebf0e35156c -r 8b0b36c2dc0c liboctave/oct-uname.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/oct-uname.h Tue Nov 29 17:41:33 2005 +0000 @@ -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 + +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: *** +*/ diff -r 3ebf0e35156c -r 8b0b36c2dc0c src/ChangeLog --- a/src/ChangeLog Tue Nov 29 17:31:04 2005 +0000 +++ b/src/ChangeLog Tue Nov 29 17:41:33 2005 +0000 @@ -1,3 +1,7 @@ +2005-11-28 John W. Eaton + + * syscalls.cc (Funame): New function. + 2005-11-21 John W. Eaton * pr-output.cc (pr_int): Fix thinko in byte-swapping for bit format. diff -r 3ebf0e35156c -r 8b0b36c2dc0c src/syscalls.cc --- a/src/syscalls.cc Tue Nov 29 17:31:04 2005 +0000 +++ b/src/syscalls.cc Tue Nov 29 17:41:33 2005 +0000 @@ -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\