Mercurial > hg > octave-lyh
changeset 11006:aca961a3f387
provide gethostname function
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 21 Sep 2010 03:35:46 -0400 |
parents | 0de4eff677d6 |
children | ffe58182db89 |
files | liboctave/ChangeLog liboctave/lo-cutils.c liboctave/lo-utils.h liboctave/oct-env.cc src/ChangeLog src/syscalls.cc src/utils.cc |
diffstat | 7 files changed, 31 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2010-09-21 John W. Eaton <jwe@octave.org> + + * oct-env.cc (do_get_host_name): Call gnulib::gethostname + instead of octave_gethostname. + + * lo-utils.h, lo-cutils.c (octave_gethostname): Delete. + 2010-09-20 John W. Eaton <jwe@octave.org> * oct-time.cc (octave_time::octave_time, octave_strptime::init):
--- a/liboctave/lo-cutils.c +++ b/liboctave/lo-cutils.c @@ -20,14 +20,6 @@ */ -/* - -The function gethostname was adapted from a similar function from GNU -Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free -Software Foundation, Inc. - -*/ - #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -67,12 +59,6 @@ return strncasecmp (s1, s2, n); } -OCTAVE_API int -octave_gethostname (char *name, int namelen) -{ - return gethostname (name, namelen); -} - #ifdef HAVE_LOADLIBRARY_API #include <windows.h>
--- a/liboctave/lo-utils.h +++ b/liboctave/lo-utils.h @@ -50,8 +50,6 @@ extern OCTAVE_API std::string octave_fgets (std::FILE *, bool& eof); extern OCTAVE_API std::string octave_fgetl (std::FILE *, bool& eof); -extern "C" OCTAVE_API int octave_gethostname (char *, int); - extern "C" OCTAVE_API void octave_qsort (void *base, size_t n, size_t size, int (*cmp) (const void *, const void *));
--- a/liboctave/oct-env.cc +++ b/liboctave/oct-env.cc @@ -450,9 +450,9 @@ { if (host_name.empty ()) { - char hostname[256]; + char hostname[1024]; - int status = octave_gethostname (hostname, 255); + int status = gnulib::gethostname (hostname, 1023); host_name = (status < 0) ? "unknown" : hostname; }
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-09-21 John W. Eaton <jwe@octave.org> + + * syscalls.cc (Fgethostname): New function. + 2010-09-20 John W. Eaton <jwe@octave.org> * DLD-FUNCTIONS/time.cc (Fmktime): New tests (bug #31079).
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -41,6 +41,7 @@ #include "file-ops.h" #include "file-stat.h" +#include "oct-env.h" #include "oct-syscalls.h" #include "oct-uname.h" @@ -1173,6 +1174,22 @@ return retval; } +DEFUN (gethostname, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\ +Return the hostname of the system on which Octave is running\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 0) + retval = octave_env::get_host_name (); + else + print_usage (); + + return retval; +} + DEFUN (uname, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{uts}, @var{err}, @var{msg}] =} uname ()\n\