Index: include/bu.h
===================================================================
--- include/bu.h	(revision 54056)
+++ include/bu.h	(working copy)
@@ -6223,6 +6223,12 @@
  */
 BU_EXPORT extern int bu_str_isprint(const char *cp);
 
+/** @file libbu/gethostname.c
+ *
+ * Portable gethostname()
+ *
+ */
+BU_EXPORT extern int bu_gethostname(char *, size_t);
 
 __END_DECLS
 
Index: src/libbu/CMakeLists.txt
===================================================================
--- src/libbu/CMakeLists.txt	(revision 54056)
+++ src/libbu/CMakeLists.txt	(working copy)
@@ -37,6 +37,7 @@
   fnmatch.c
   fopen_uniq.c
   getcwd.c
+  gethostname.c
   getopt.c
   globals.c
   hash.c
Index: src/libbu/gethostname.c
===================================================================
--- src/libbu/gethostname.c	(revision 0)
+++ src/libbu/gethostname.c	(working copy)
@@ -0,0 +1,57 @@
+/*                       G E T H O S T N A M E . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2004-2012 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+#include "common.h"
+
+#include "bio.h"
+#include "bin.h"
+
+#include "bu.h"
+
+/**
+ * Windows requires some initialisations before gethostname() can be used.
+ */
+int
+bu_gethostname(char *hostname, size_t hostlen)
+{
+    int status;
+
+#if defined(WIN32)
+    WSADATA wsaData;
+    WSAStartup(MAKEWORD(2, 2), &wsaData);
+#endif
+
+    status = gethostname(hostname, hostlen);
+
+#if defined(WIN32)
+    WSACleanup();
+#endif
+
+    return status;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */

Property changes on: src/libbu/gethostname.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: src/libbu/tests/CMakeLists.txt
===================================================================
--- src/libbu/tests/CMakeLists.txt	(revision 54056)
+++ src/libbu/tests/CMakeLists.txt	(working copy)
@@ -1,4 +1,5 @@
 BRLCAD_ADDEXEC(tester_bu_sscanf bu_sscanf.c libbu NO_INSTALL LOCAL)
+BRLCAD_ADDEXEC(tester_bu_gethostname bu_gethostname.c libbu NO_INSTALL LOCAL)
 
 #
 #  ************ basename.c tests *************
Index: src/libbu/tests/bu_gethostname.c
===================================================================
--- src/libbu/tests/bu_gethostname.c	(revision 0)
+++ src/libbu/tests/bu_gethostname.c	(working copy)
@@ -0,0 +1,50 @@
+/*                 T E S T _ G E T H O S T N A M E . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2011-2012 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+
+#include "common.h"
+
+#include <stdio.h>
+
+#include "bu.h"
+
+
+int
+main(void)
+{
+    char host[100];
+    int status;
+
+    status = bu_gethostname(host, 100);
+    printf("%s\n", host);
+    printf("%d\n", status);
+
+    return status;
+}
+
+
+/*
+ * Local Variables:
+ * mode: C
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */

Property changes on: src/libbu/tests/bu_gethostname.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
