gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3059 - in GNUnet/src: include setup util util/os


From: durner
Subject: [GNUnet-SVN] r3059 - in GNUnet/src: include setup util util/os
Date: Mon, 26 Jun 2006 08:11:17 -0700 (PDT)

Author: durner
Date: 2006-06-26 08:11:08 -0700 (Mon, 26 Jun 2006)
New Revision: 3059

Added:
   GNUnet/src/util/os/time.c
Removed:
   GNUnet/src/util/time.c
Modified:
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/include/gnunet_util_os.h
   GNUnet/src/setup/wizard_util.c
   GNUnet/src/util/initialize.c
   GNUnet/src/util/os/Makefile.am
Log:
move platform specifics

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/include/gnunet_util.h    2006-06-26 15:11:08 UTC (rev 3059)
@@ -88,33 +88,6 @@
 
 /* CHRISTIAN: move this to gnunet_core.h or _protocols.h ? */
 
-/* NILS: I would love to see the 
-   next two methods in PLIBC */
-
-typedef unsigned int TIME_T;
-
-/**
- * TIME prototype. "man time".
- */
-TIME_T TIME(TIME_T * t);
-
-/**
- * "man ctime_r".
- * @return character sequence describing the time,
- *  must be freed by caller
- */
-char * GN_CTIME(const TIME_T * t);
-
-/** NILS: the next one should be removed from gnunetutil --
-    we should not have anything win32 specific in here! */
-
-/**
- * @brief Format a Windows specific error code
- */
-char *winErrorStr(const char *prefix, 
-                 int dwErr);
-
-
 /* FIXME: these functions need to be replaced with
    functions that are appropriate for bootstrapping
    the new gnunetutil library (i.e. setup error,

Modified: GNUnet/src/include/gnunet_util_os.h
===================================================================
--- GNUnet/src/include/gnunet_util_os.h 2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/include/gnunet_util_os.h 2006-06-26 15:11:08 UTC (rev 3059)
@@ -43,6 +43,11 @@
 #endif
 
 /**
+ * 32-bit timer value.
+ */
+typedef unsigned int TIME_T;
+
+/**
  * @brief Inter-process semaphore.
  */
 struct IPC_SEMAPHORE;
@@ -53,6 +58,18 @@
 struct PluginHandle;
 
 /**
+ * TIME prototype. "man time".
+ */
+TIME_T TIME(TIME_T * t);
+
+/**
+ * "man ctime_r".
+ * @return character sequence describing the time,
+ *  must be freed by caller
+ */
+char * GN_CTIME(const TIME_T * t);
+
+/**
  * @param isDefault is this presumably the default interface
  * @return OK to continue iteration, SYSERR to abort
  */

Modified: GNUnet/src/setup/wizard_util.c
===================================================================
--- GNUnet/src/setup/wizard_util.c      2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/setup/wizard_util.c      2006-06-26 15:11:08 UTC (rev 3059)
@@ -30,6 +30,36 @@
 #define LKC_DIRECT_LINK
 #include "lkc.h"
 
+char * winErrorStr(const char *prefix, 
+       int dwErr) {
+#ifdef WINDOWS
+  char *err, *ret;
+  int mem;
+  
+  if (! FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM,
+          NULL, 
+          (DWORD) dwErr, 
+          MAKELANGID(LANG_NEUTRAL, 
+         SUBLANG_DEFAULT), 
+          (LPTSTR) &err,
+          0,
+          NULL )) {
+    err = "";
+  }
+  
+  mem = strlen(err) + strlen(prefix) + 20;
+  ret = (char *) malloc(mem);
+  
+  snprintf(ret, mem, "%s: %s (#%u)", 
+     prefix, 
+     err, 
+     dwErr);
+  LocalFree(err);
+  return ret;
+#else
+  return NULL;
+#endif
+}
 
 /**
  * @brief Determine whether a NIC makes a good default

Modified: GNUnet/src/util/initialize.c
===================================================================
--- GNUnet/src/util/initialize.c        2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/util/initialize.c        2006-06-26 15:11:08 UTC (rev 3059)
@@ -131,40 +131,4 @@
 }
 
 
-
-
-char * winErrorStr(const char *prefix, 
-                  int dwErr) {
-#ifdef WINDOWS
-  char *err, *ret;
-  int mem;
-  
-  if (! FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM,
-                     NULL, 
-                     (DWORD) dwErr, 
-                     MAKELANGID(LANG_NEUTRAL, 
-                                SUBLANG_DEFAULT), 
-                     (LPTSTR) &err,
-                     0,
-                     NULL )) {
-    err = "";
-  }
-  
-  mem = strlen(err) + strlen(prefix) + 20;
-  ret = (char *) malloc(mem);
-  
-  snprintf(ret, mem, "%s: %s (#%u)", 
-          prefix, 
-          err, 
-          dwErr);
-  LocalFree(err);
-  return ret;
-#else
-       return NULL;
-#endif
-}
-
-
-
-
 /* end of initialize.c */

Modified: GNUnet/src/util/os/Makefile.am
===================================================================
--- GNUnet/src/util/os/Makefile.am      2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/util/os/Makefile.am      2006-06-26 15:11:08 UTC (rev 3059)
@@ -11,7 +11,8 @@
  dso.c \
  osconfig.c \
  semaphore.c \
- statuscalls.c 
+ statuscalls.c \
+ time.c
 
 check_PROGRAMS = \
  daemontest \

Added: GNUnet/src/util/os/time.c
===================================================================
--- GNUnet/src/util/os/time.c   2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/util/os/time.c   2006-06-26 15:11:08 UTC (rev 3059)
@@ -0,0 +1,59 @@
+/*
+     This file is part of GNUnet.
+     (C) 2006 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file util/os/time.c
+ * @brief wrappers for time functions
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_util_os.h"
+
+/**
+ * TIME prototype. "man time".
+ */
+TIME_T TIME(TIME_T * t) {
+  TIME_T now;
+
+  now = (TIME_T) time(NULL); /* potential 64-bit to 32-bit conversion!*/
+  if (t != NULL)
+    *t = now;
+  return now;
+}
+
+/**
+ * "man ctime_r".  Automagically expands the 32-bit
+ * GNUnet time value to a 64-bit value of the current
+ * epoc if needed.
+ */
+char * GN_CTIME(const TIME_T * t) {
+  TIME_T now;
+  time_t tnow;
+
+  tnow = time(NULL);
+  now = (TIME_T) tnow;
+  tnow = tnow - now + *t;
+#ifdef ctime_r
+  return ctime_r(&tnow, MALLOC(32));
+#else
+  return STRDUP(ctime(&tnow));
+#endif
+}

Deleted: GNUnet/src/util/time.c
===================================================================
--- GNUnet/src/util/time.c      2006-06-25 21:50:22 UTC (rev 3058)
+++ GNUnet/src/util/time.c      2006-06-26 15:11:08 UTC (rev 3059)
@@ -1,34 +0,0 @@
-
-#include "gnunet_util.h"
-#include "platform.h"
-
-/**
- * TIME prototype. "man time".
- */
-TIME_T TIME(TIME_T * t) {
-  TIME_T now;
-
-  now = (TIME_T) time(NULL); /* potential 64-bit to 32-bit conversion!*/
-  if (t != NULL)
-    *t = now;
-  return now;
-}
-
-/**
- * "man ctime_r".  Automagically expands the 32-bit
- * GNUnet time value to a 64-bit value of the current
- * epoc if needed.
- */
-char * GN_CTIME(const TIME_T * t) {
-  TIME_T now;
-  time_t tnow;
-
-  tnow = time(NULL);
-  now = (TIME_T) tnow;
-  tnow = tnow - now + *t;
-#ifdef ctime_r
-  return ctime_r(&tnow, MALLOC(32));
-#else
-  return STRDUP(ctime(&tnow));
-#endif
-}





reply via email to

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