+ This program 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 this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* written by Jim Meyering */
+
+#include <config.h>
+
+/* Specification. */
+#include "xgethostname.h"
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "xalloc.h"
+
+#ifndef ENAMETOOLONG
+# define ENAMETOOLONG 0
+#endif
+
+#ifndef INITIAL_HOSTNAME_LENGTH
+# define INITIAL_HOSTNAME_LENGTH 34
+#endif
+
+/* Return the current hostname in malloc'd storage.
+ If malloc fails, exit.
+ Upon any other failure, return NULL and set errno. */