# HG changeset patch # User John W. Eaton # Date 1285054546 14400 # Node ID aca961a3f387c74d077c6114fa2c171480007e42 # Parent 0de4eff677d6b5f96ef4eea771dc32b77d834cb5 provide gethostname function diff -r 0de4eff677d6 -r aca961a3f387 liboctave/ChangeLog --- a/liboctave/ChangeLog Mon Sep 20 21:23:10 2010 -0400 +++ b/liboctave/ChangeLog Tue Sep 21 03:35:46 2010 -0400 @@ -1,3 +1,10 @@ +2010-09-21 John W. Eaton + + * 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 * oct-time.cc (octave_time::octave_time, octave_strptime::init): diff -r 0de4eff677d6 -r aca961a3f387 liboctave/lo-cutils.c --- a/liboctave/lo-cutils.c Mon Sep 20 21:23:10 2010 -0400 +++ b/liboctave/lo-cutils.c Tue Sep 21 03:35:46 2010 -0400 @@ -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 #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 diff -r 0de4eff677d6 -r aca961a3f387 liboctave/lo-utils.h --- a/liboctave/lo-utils.h Mon Sep 20 21:23:10 2010 -0400 +++ b/liboctave/lo-utils.h Tue Sep 21 03:35:46 2010 -0400 @@ -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 *)); diff -r 0de4eff677d6 -r aca961a3f387 liboctave/oct-env.cc --- a/liboctave/oct-env.cc Mon Sep 20 21:23:10 2010 -0400 +++ b/liboctave/oct-env.cc Tue Sep 21 03:35:46 2010 -0400 @@ -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; } diff -r 0de4eff677d6 -r aca961a3f387 src/ChangeLog --- a/src/ChangeLog Mon Sep 20 21:23:10 2010 -0400 +++ b/src/ChangeLog Tue Sep 21 03:35:46 2010 -0400 @@ -1,3 +1,7 @@ +2010-09-21 John W. Eaton + + * syscalls.cc (Fgethostname): New function. + 2010-09-20 John W. Eaton * DLD-FUNCTIONS/time.cc (Fmktime): New tests (bug #31079). diff -r 0de4eff677d6 -r aca961a3f387 src/syscalls.cc --- a/src/syscalls.cc Mon Sep 20 21:23:10 2010 -0400 +++ b/src/syscalls.cc Tue Sep 21 03:35:46 2010 -0400 @@ -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\ diff -r 0de4eff677d6 -r aca961a3f387 src/utils.cc --- a/src/utils.cc Mon Sep 20 21:23:10 2010 -0400 +++ b/src/utils.cc Tue Sep 21 03:35:46 2010 -0400 @@ -42,6 +42,7 @@ #include "file-ops.h" #include "file-stat.h" #include "lo-mappers.h" +#include "lo-utils.h" #include "oct-cmplx.h" #include "oct-env.h" #include "pathsearch.h"