[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Make testcases run again; more sanity checking to descripto...



Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv9427/src/common

Modified Files:
	util.c util.h 
Log Message:
Make testcases run again; more sanity checking to descriptor generation.

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- util.c	29 Sep 2003 23:14:45 -0000	1.23
+++ util.c	1 Oct 2003 22:31:12 -0000	1.24
@@ -12,6 +12,9 @@
 
 #include "util.h"
 #include "log.h"
+#ifdef HAVE_UNAME
+#include <sys/utsname.h>
+#endif
 
 /*
  *    Memory
@@ -480,3 +483,28 @@
   return 1;
 }
 
+static char uname_result[256];
+static int uname_result_is_set = 0;
+
+const char *
+get_uname(void)
+{
+#ifdef HAVE_UNAME
+  struct utsname u;
+#endif
+  if (!uname_result_is_set) {
+#ifdef HAVE_UNAME
+    if (!uname((&u))) {
+      snprintf(uname_result, 255, "%s %s %s %s %s",
+               u.sysname, u.nodename, u.release, u.version, u.machine);
+      uname_result[255] = '\0';
+    } else 
+#endif
+      {
+        strcpy(uname_result, "Unknown platform");
+      }
+    uname_result_is_set = 1;
+  }
+  return uname_result;
+}
+      

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- util.h	29 Sep 2003 07:50:05 -0000	1.14
+++ util.h	1 Oct 2003 22:31:12 -0000	1.15
@@ -72,6 +72,8 @@
 
 int tor_socketpair(int family, int type, int protocol, int fd[2]);
 
+const char *get_uname(void);
+
 /* For stupid historical reasons, windows sockets have an independent set of 
  * errnos which they use as the fancy strikes them.
  */