diff rogue4/mdport.c @ 122:65f3da34578a

rogue4, arogue5: improve portability. Most changes merely prevent including header files that don't exist. All games now build and run on MinGW, though bugs remain.
author John "Elwin" Edwards
date Wed, 07 May 2014 14:08:38 -0700
parents ba9930a7f99d
children 600873555ec0
line wrap: on
line diff
--- a/rogue4/mdport.c	Sat May 03 10:31:30 2014 -0700
+++ b/rogue4/mdport.c	Wed May 07 14:08:38 2014 -0700
@@ -29,6 +29,10 @@
     SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #if defined(_WIN32)
 #include <Windows.h>
 #include <Lmcons.h>
@@ -40,10 +44,15 @@
 #undef MOUSE_MOVED
 #elif defined(__DJGPP__)
 #include <process.h>
-#else
+#endif
+
+#ifdef HAVE_PWD_H
 #include <pwd.h>
-#include <sys/utsname.h>
+#endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #endif
 
@@ -60,7 +69,7 @@
 #endif
 
 #include <curses.h>
-#if !defined(DJGPP)
+#ifdef HAVE_TERM_H
 #include <term.h>
 #endif
 
@@ -657,28 +666,6 @@
 #endif
 }
 
-char *
-md_gethostname()
-{
-    static char nodename[80];
-    char *n = NULL;
-#if !defined(_WIN32) && !defined(__DJGPP__)
-    struct utsname ourname;
-
-    if (uname(&ourname) == 0)
-        n = ourname.nodename;
-#endif
-    if ((n == NULL) || (*n == '\0'))
-        if ( (n = getenv("COMPUTERNAME")) == NULL)
-            if ( (n = getenv("HOSTNAME")) == NULL)
-                n = "localhost";
-
-    strncpy(nodename, n, 80);
-    nodename[79] = 0;
-
-    return(nodename);
-}
-
 int
 md_erasechar()
 {