Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: Freeciv for windows
Home

[Freeciv-Dev] Re: Freeciv for windows

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Paul Zastoupil <paulz@xxxxxxxxxxxx>
Cc: Andreas Kemnade <akemnade@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Freeciv for windows
From: Andreas Kemnade <akemnade@xxxxxxxxxxx>
Date: Sun, 28 Oct 2001 19:40:39 +0100

Paul Zastoupil writes:
 > On Tue, Oct 23, 2001 at 09:13:27PM +0200, Andreas Kemnade wrote:
 > > Paul Zastoupil writes:
 > >  
 > >  > 
 > >  > uname.cc attached.  Does this help?
 > >  > 
 > > It contains code to recognize the cpu used. That does help.
 > > But the other stuff is mostly cygwin-specific (version numbers if
 > > cygwin.dll). I'll post a patch when I have finished the metaserver
 > > dialog. I have looked a bit into a windows book and I think I can
 > > create a string in the following form:
 > > Freeciv/1.12.1-devel gui-win32 Win98 4.1 [i686]
 > 
 > Well, that would make me one happy camper :)
I've finished that stuff now.
Are the User-Agent: strings now correct and sensible?

Greetings
Andreas Kemnade

diff --exclude-from freeciv/diff_ignore -Nur freeciv/client/clinet.c 
/mnt/win/devel/freeciv/client/clinet.c
--- freeciv/client/clinet.c     Fri Oct 12 15:16:50 2001
+++ /mnt/win/devel/freeciv/client/clinet.c      Sun Oct 28 16:22:04 2001
@@ -382,6 +382,62 @@
   }
 }
 
+#ifdef WIN32_NATIVE
+/*****************************************************************
+   Returns an uname like string for windows
+*****************************************************************/
+static char *win_uname()
+{
+  static char uname_buf[256];
+  char cpuname[16];
+  char osname[64];
+  SYSTEM_INFO sysinfo;
+  OSVERSIONINFO osvi;
+  osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
+  GetVersionEx(&osvi);
+  if (osvi.dwPlatformId==VER_PLATFORM_WIN32_NT) {
+    if ((osvi.dwMajorVersion==5)&&(osvi.dwMinorVersion==0)) {
+      sz_strlcpy(osname,"Win2000");
+    } else {
+      sz_strlcpy(osname,"WinNT");
+    }
+  } else {
+    strcpy(osname,osvi.szCSDVersion);
+  }
+  GetSystemInfo(&sysinfo); 
+  switch (sysinfo.wProcessorArchitecture)
+    {
+    case PROCESSOR_ARCHITECTURE_INTEL:
+      {
+       unsigned int ptype;
+       if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
+         ptype = 3;
+       else if (sysinfo.wProcessorLevel > 9) /* P4 */
+         ptype = 6;
+       else
+         ptype = sysinfo.wProcessorLevel;
+       
+       sprintf (cpuname, "i%d86", ptype);
+       break;
+      }
+    case PROCESSOR_ARCHITECTURE_ALPHA:
+      sz_strlcpy (cpuname, "alpha");
+      break;
+    case PROCESSOR_ARCHITECTURE_MIPS:
+      sz_strlcpy (cpuname, "mips");
+      break;
+    default:
+      sz_strlcpy (cpuname, "unknown");
+      break;
+    }
+  my_snprintf(uname_buf,sizeof(uname_buf),
+             "%s %ld.%ld [%s]",osname,osvi.dwMajorVersion,osvi.dwMinorVersion,
+             cpuname);
+  return uname_buf;
+}
+#endif
+
+
 #define SPECLIST_TAG server
 #define SPECLIST_TYPE struct server
 #include "speclist_c.h"
@@ -484,8 +540,12 @@
 #else /* ! HAVE_UNAME */
   /* Fill in here if you are making a binary without sys/utsname.h and know
      the OS name, release number, and machine architechture */
+#ifdef WIN32_NATIVE
+  sz_strlcpy(machine_string,win_uname());
+#else
   my_snprintf(machine_string,sizeof(machine_string),
               "unknown unknown [unknown]");
+#endif
 #endif /* HAVE_UNAME */
 
   my_snprintf(str,sizeof(str),

[Prev in Thread] Current Thread [Next in Thread]