Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] (PR#11170) Add -x extra information client command option.
Home

[Freeciv-Dev] (PR#11170) Add -x extra information client command option.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11170) Add -x extra information client command option.
From: "Vasco Alexandre da Silva Costa" <vasco.costa@xxxxxxxxx>
Date: Sat, 3 Dec 2005 08:40:42 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11170 >

> [vasc - Sat Dec 03 16:33:21 2005]:
> 
> I split the my_uname function merge into a separate patch. Patch
> attached, to commit ASAP.

This patch changes my_uname to be reentrant.

Index: client/servers.c
===================================================================
--- client/servers.c    (revision 11295)
+++ client/servers.c    (working copy)
@@ -172,16 +172,14 @@
 /*****************************************************************
   Returns an uname like string.
 *****************************************************************/
-static const char *my_uname(void)
+static void my_uname(char *buf, size_t len)
 {
-  static char machine_string[128];
-
 #ifdef HAVE_UNAME
   {
     struct utsname un;
 
     uname(&un);
-    my_snprintf(machine_string, sizeof(machine_string),
+    my_snprintf(buf, len,
                "%s %s [%s]",
                un.sysname,
                un.release,
@@ -271,17 +269,16 @@
        sz_strlcpy(cpuname, "unknown");
        break;
     }
-    my_snprintf(machine_string, sizeof(machine_string),
-               "%s %ld.%ld [%s]", osname, osvi.dwMajorVersion, 
osvi.dwMinorVersion,
+    my_snprintf(buf, len,
+               "%s %ld.%ld [%s]",
+               osname, osvi.dwMajorVersion, osvi.dwMinorVersion,
                cpuname);
   }
 #else
-  my_snprintf(machine_string, sizeof(machine_string),
+  my_snprintf(buf, len,
               "unknown unknown [unknown]");
 #endif
 #endif /* HAVE_UNAME */
-
-  return machine_string;
 }
 
 /****************************************************************************
@@ -293,7 +290,7 @@
   char str[MAX_LEN_PACKET];
   char machine_string[128];
 
-  sz_strlcpy(machine_string, my_uname());
+  my_uname(machine_string, sizeof(machine_string));
 
   capstr = my_url_encode(our_capability);
 

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