gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8587 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r8587 - in gnunet/src: include util
Date: Tue, 16 Jun 2009 14:13:13 -0600

Author: durner
Date: 2009-06-16 14:13:13 -0600 (Tue, 16 Jun 2009)
New Revision: 8587

Removed:
   gnunet/src/include/gnunet_io_lib.h
   gnunet/src/util/io_handle.c
   gnunet/src/util/io_handle.h
Modified:
   gnunet/src/include/Makefile.am
   gnunet/src/include/gnunet_disk_lib.h
   gnunet/src/include/gnunet_util_lib.h
   gnunet/src/util/Makefile.am
   gnunet/src/util/container_bloomfilter.c
   gnunet/src/util/crypto_hash.c
   gnunet/src/util/disk.c
   gnunet/src/util/test_disk.c
   gnunet/src/util/test_os_load.c
Log:
GNUNET_IO_handle => GNUNET_DISK_handle

Modified: gnunet/src/include/Makefile.am
===================================================================
--- gnunet/src/include/Makefile.am      2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/include/Makefile.am      2009-06-16 20:13:13 UTC (rev 8587)
@@ -24,7 +24,6 @@
   gnunet_fragmentation_lib.h \
   gnunet_getopt_lib.h \
   gnunet_hello_lib.h \
-  gnunet_io_lib.h \
   gnunet_network_lib.h \
   gnunet_peerinfo_service.h \
   gnunet_program_lib.h \

Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h        2009-06-16 18:35:49 UTC (rev 
8586)
+++ gnunet/src/include/gnunet_disk_lib.h        2009-06-16 20:13:13 UTC (rev 
8587)
@@ -28,7 +28,6 @@
 
 #include "gnunet_configuration_lib.h"
 #include "gnunet_scheduler_lib.h"
-#include "gnunet_io_lib.h"
 
 /* we need size_t, and since it can be both unsigned int
    or unsigned long long, this IS platform dependent;
@@ -75,6 +74,8 @@
 
 enum GNUNET_DISK_Seek {GNUNET_SEEK_SET, GNUNET_SEEK_CUR, GNUNET_SEEK_END};
 
+struct GNUNET_IO_Handle;
+
 /**
  * Get the number of blocks that are left on the partition that
  * contains the given file (for normal users).
@@ -86,6 +87,14 @@
 
 
 /**
+ * Checks whether a handle is invalid
+ * @param h handle to check
+ * @return GNUNET_YES if invalid, GNUNET_NO if valid
+ */
+int GNUNET_DISK_handle_invalid (const struct GNUNET_IO_Handle *h);
+
+
+/**
  * Check that fil corresponds to a filename
  * (of a file that exists and that is not a directory).
  *
@@ -153,7 +162,7 @@
  * @param fn file name
  * @param result the buffer to write the result to
  * @param len the maximum number of bytes to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return number of bytes read, GNUNET_SYSERR on failure
  */
 int GNUNET_DISK_fn_read (const char * const fn, void *result, int len);
 

Deleted: gnunet/src/include/gnunet_io_lib.h
===================================================================
--- gnunet/src/include/gnunet_io_lib.h  2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/include/gnunet_io_lib.h  2009-06-16 20:13:13 UTC (rev 8587)
@@ -1,46 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 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 include/gnunet_io_lib.h
- * @brief Helper functions for abstract IO handles
- * @author Nils Durner
- */
-
-#ifndef IO_HANDLE_H_
-#define IO_HANDLE_H_
-
-struct GNUNET_IO_Handle;
-
-/**
- * Checks whether a handle is invalid
- * @param h handle to check
- * @return GNUNET_YES if invalid, GNUNET_NO if valid
- */
-int GNUNET_IO_handle_invalid (const struct GNUNET_IO_Handle *h);
-
-/**
- * Mark a handle as invalid
- * @param h file handle
- */
-void GNUNET_IO_handle_invalidate (struct GNUNET_IO_Handle *h);
-
-
-#endif /* IO_HANDLE_H_ */

Modified: gnunet/src/include/gnunet_util_lib.h
===================================================================
--- gnunet/src/include/gnunet_util_lib.h        2009-06-16 18:35:49 UTC (rev 
8586)
+++ gnunet/src/include/gnunet_util_lib.h        2009-06-16 20:13:13 UTC (rev 
8587)
@@ -43,7 +43,6 @@
 #include "gnunet_crypto_lib.h"
 #include "gnunet_disk_lib.h"
 #include "gnunet_getopt_lib.h"
-#include "gnunet_io_lib.h"
 #include "gnunet_network_lib.h"
 #include "gnunet_plugin_lib.h"
 #include "gnunet_program_lib.h"

Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/Makefile.am 2009-06-16 20:13:13 UTC (rev 8587)
@@ -33,8 +33,6 @@
   disk.c \
   getopt.c \
   getopt_helpers.c \
-  io_handle.c \
-  io_handle.h \
   network.c \
   os_installation.c \
   os_load.c \

Modified: gnunet/src/util/container_bloomfilter.c
===================================================================
--- gnunet/src/util/container_bloomfilter.c     2009-06-16 18:35:49 UTC (rev 
8586)
+++ gnunet/src/util/container_bloomfilter.c     2009-06-16 20:13:13 UTC (rev 
8587)
@@ -151,7 +151,7 @@
   unsigned int targetLoc;
 
   setBit (bitArray, bitIdx);
-  if (GNUNET_IO_handle_invalid (fh))
+  if (GNUNET_DISK_handle_invalid (fh))
     return;
   /* Update the counter file on disk */
   fileSlot = bitIdx / 2;
@@ -195,7 +195,7 @@
   unsigned int low;
   unsigned int targetLoc;
 
-  if (GNUNET_IO_handle_invalid (fh))
+  if (GNUNET_DISK_handle_invalid (fh))
     return;                     /* cannot decrement! */
   /* Each char slot in the counter file holds two 4 bit counters */
   fileSlot = bitIdx / 2;
@@ -246,7 +246,7 @@
   unsigned int bytesleft = size;
   int res = 0;
 
-  if (GNUNET_IO_handle_invalid (fh))
+  if (GNUNET_DISK_handle_invalid (fh))
     return GNUNET_SYSERR;
   buffer = GNUNET_malloc (BUFFSIZE);
   memset (buffer, 0, BUFFSIZE);

Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c       2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/crypto_hash.c       2009-06-16 20:13:13 UTC (rev 8587)
@@ -443,7 +443,7 @@
 {
   fhc->callback (fhc->callback_cls, res);
   GNUNET_free (fhc->filename);
-  if (!GNUNET_IO_handle_invalid (fhc->fh))
+  if (!GNUNET_DISK_handle_invalid (fhc->fh))
     GNUNET_break (0 == GNUNET_DISK_file_close (&fhc->fh));
   GNUNET_free (fhc);            /* also frees fhc->buffer */
 }

Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c      2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/disk.c      2009-06-16 20:13:13 UTC (rev 8587)
@@ -26,10 +26,8 @@
  */
 
 #include "platform.h"
-#include "io_handle.h"
 #include "gnunet_common.h"
 #include "gnunet_directories.h"
-#include "gnunet_io_lib.h"
 #include "gnunet_disk_lib.h"
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_strings_lib.h"
@@ -76,6 +74,15 @@
   int include_sym_links;
 } GetFileSizeData;
 
+struct GNUNET_IO_Handle
+{
+#if MINGW
+  HANDLE h;
+#else
+  int fd;
+#endif
+};
+
 static int
 getSizeRec (void *ptr, const char *fn)
 {
@@ -111,8 +118,36 @@
   return GNUNET_OK;
 }
 
+/**
+ * Checks whether a handle is invalid
+ * @param h handle to check
+ * @return GNUNET_YES if invalid, GNUNET_NO if valid
+ */
+int
+GNUNET_DISK_handle_invalid (const struct GNUNET_IO_Handle *h)
+{
+#ifdef MINGW
+  return !h || h->h == INVALID_HANDLE_VALUE ? GNUNET_YES : GNUNET_NO;
+#else
+  return !h || h->fd == -1 ? GNUNET_YES : GNUNET_NO;
+#endif
+}
 
 /**
+ * Mark a handle as invalid
+ * @param h file handle
+ */
+static void
+GNUNET_DISK_handle_invalidate (struct GNUNET_IO_Handle *h)
+{
+#ifdef MINGW
+  h->h = INVALID_HANDLE_VALUE;
+#else
+  h->fd = -1;
+#endif
+}
+
+/**
  * Move the read/write pointer in a file
  * @param h handle of an open file
  * @param offset position to move to
@@ -435,7 +470,7 @@
  * @param fn file name
  * @param result the buffer to write the result to
  * @param len the maximum number of bytes to read
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @return number of bytes read, GNUNET_SYSERR on failure
  */
 int
 GNUNET_DISK_fn_read (const char * const fn, void *result, int len)
@@ -446,7 +481,7 @@
   fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ);
   if (!fh)
     return GNUNET_SYSERR;
-  ret = (len == GNUNET_DISK_file_read (fh, result, len)) ? GNUNET_OK : 
GNUNET_SYSERR;
+  ret = GNUNET_DISK_file_read (fh, result, len);
   GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(&fh));
 
   return ret;
@@ -1094,7 +1129,7 @@
   }
 #endif
 
-  GNUNET_IO_handle_invalidate (*h);
+  GNUNET_DISK_handle_invalidate (*h);
   free(*h);
   *h = NULL;
 
@@ -1272,7 +1307,7 @@
       SetErrnoFromWinError (GetLastError ());
     }
 
-  GNUNET_IO_handle_invalidate (*h);
+  GNUNET_DISK_handle_invalidate (*h);
   GNUNET_free (*h);
   h = NULL;
 
@@ -1280,7 +1315,7 @@
 #else
   int ret;
   ret = munmap (addr, len) != -1 ? GNUNET_OK : GNUNET_SYSERR;
-  GNUNET_IO_handle_invalidate (h);
+  GNUNET_DISK_handle_invalidate (*h);
   return ret;
 #endif
 }

Deleted: gnunet/src/util/io_handle.c
===================================================================
--- gnunet/src/util/io_handle.c 2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/io_handle.c 2009-06-16 20:13:13 UTC (rev 8587)
@@ -1,58 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 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/io_handle.c
- * @brief common functions for IO handles
- * @author Nils Durner
- */
-#include "platform.h"
-#include "io_handle.h"
-#include "gnunet_common.h"
-
-/**
- * Checks whether a handle is invalid
- * @param h handle to check
- * @return GNUNET_YES if invalid, GNUNET_NO if valid
- */
-int
-GNUNET_IO_handle_invalid (const struct GNUNET_IO_Handle *h)
-{
-#ifdef MINGW
-  return !h || h->h == INVALID_HANDLE_VALUE ? GNUNET_YES : GNUNET_NO;
-#else
-  return !h || h->fd == -1 ? GNUNET_YES : GNUNET_NO;
-#endif
-}
-
-/**
- * Mark a handle as invalid
- * @param h file handle
- */
-void
-GNUNET_IO_handle_invalidate (struct GNUNET_IO_Handle *h)
-{
-#ifdef MINGW
-  h->h = INVALID_HANDLE_VALUE;
-#else
-  h->fd = -1;
-#endif
-}
-
-/* end of io_handle.c */

Deleted: gnunet/src/util/io_handle.h
===================================================================
--- gnunet/src/util/io_handle.h 2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/io_handle.h 2009-06-16 20:13:13 UTC (rev 8587)
@@ -1,38 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 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/io_handle.h
- * @brief wrapper structure for file handles, sockets, ...
- */
-
-#ifndef IO_HANDLE_H_
-#define IO_HANDLE_H_
-
-struct GNUNET_IO_Handle
-{
-#if MINGW
-  HANDLE h;
-#else
-  int fd;
-#endif
-};
-
-#endif /* IO_HANDLE_H_ */

Modified: gnunet/src/util/test_disk.c
===================================================================
--- gnunet/src/util/test_disk.c 2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/test_disk.c 2009-06-16 20:13:13 UTC (rev 8587)
@@ -92,7 +92,7 @@
   fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE
       | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ
       | GNUNET_DISK_PERM_USER_WRITE);
-  GNUNET_assert (GNUNET_NO == GNUNET_IO_handle_invalid (fh));
+  GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh));
   GNUNET_break (5 == GNUNET_DISK_file_write (fh, "Hello", 5));
   GNUNET_DISK_file_close (&fh);
   GNUNET_break (GNUNET_OK ==
@@ -108,7 +108,7 @@
   fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE
       | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_WRITE
       | GNUNET_DISK_PERM_USER_READ);
-  GNUNET_assert (GNUNET_NO == GNUNET_IO_handle_invalid (fh));
+  GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh));
   while ((avail == GNUNET_DISK_get_blocks_available (".testfile")) &&
          (avail != -1))
     if (16 != GNUNET_DISK_file_write (fh, "HelloWorld123456", 16))

Modified: gnunet/src/util/test_os_load.c
===================================================================
--- gnunet/src/util/test_os_load.c      2009-06-16 18:35:49 UTC (rev 8586)
+++ gnunet/src/util/test_os_load.c      2009-06-16 20:13:13 UTC (rev 8587)
@@ -135,7 +135,7 @@
   fh = GNUNET_DISK_file_open (".loadfile", GNUNET_DISK_OPEN_WRITE
       | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ
       | GNUNET_DISK_PERM_USER_WRITE);
-  GNUNET_assert (GNUNET_NO == GNUNET_IO_handle_invalid(fh));
+  GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid(fh));
   while (GNUNET_TIME_absolute_get_duration (start).value < 60 * 1000)
     {
       GNUNET_DISK_file_seek (fh, GNUNET_CRYPTO_random_u64 
(GNUNET_CRYPTO_QUALITY_WEAK,





reply via email to

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