[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9210 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9210 - in gnunet/src: include util |
Date: |
Mon, 19 Oct 2009 16:28:37 -0600 |
Author: grothoff
Date: 2009-10-19 16:28:37 -0600 (Mon, 19 Oct 2009)
New Revision: 9210
Modified:
gnunet/src/include/gnunet_bio_lib.h
gnunet/src/util/bio.c
gnunet/src/util/test_bio.c
Log:
fixing bio bugs
Modified: gnunet/src/include/gnunet_bio_lib.h
===================================================================
--- gnunet/src/include/gnunet_bio_lib.h 2009-10-19 22:00:02 UTC (rev 9209)
+++ gnunet/src/include/gnunet_bio_lib.h 2009-10-19 22:28:37 UTC (rev 9210)
@@ -113,7 +113,7 @@
* @param h hande to open file
* @param f address of float to read
*/
-#define GNUNET_BIO_read_float(h, f) (sizeof(float) == GNUNET_BIO_read (h,
__FILE__ "##__LINE__##", f, sizeof(float)))
+#define GNUNET_BIO_read_float(h, f) (GNUNET_BIO_read (h, __FILE__
"##__LINE__##", f, sizeof(float)))
@@ -123,7 +123,7 @@
* @param h hande to open file
* @param f address of double to read
*/
-#define GNUNET_BIO_read_double(h, f) (sizeof(double) == GNUNET_BIO_read (h,
__FILE__ "##__LINE__##", f, sizeof(double)))
+#define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read (h, __FILE__
"##__LINE__##", f, sizeof(double)))
/**
@@ -167,7 +167,7 @@
* @param h hande to open file
* @param i address of 64-bit integer to read
*/
-#define GNUNET_BIO_read_int64(h, i) (sizeof(int64_t) == GNUNET_BIO_read (h,
__FILE__ "##__LINE__##", (int64_t*) i, sizeof(int64_t)))
+#define GNUNET_BIO_read_int64(h, i) GNUNET_BIO_read_int64__ (h, __FILE__
"##__LINE__##", (int64_t*) i)
/**
@@ -236,7 +236,7 @@
* @param h hande to open file
* @param f float to write (must be a variable)
*/
-#define GNUNET_BIO_write_float(h, f) (sizeof(float) == GNUNET_BIO_write (h,
&f, sizeof(float)))
+#define GNUNET_BIO_write_float(h, f) GNUNET_BIO_write (h, &f, sizeof(float))
@@ -246,7 +246,7 @@
* @param h hande to open file
* @param f double to write (must be a variable)
*/
-#define GNUNET_BIO_write_double(h, f) (sizeof(double) == GNUNET_BIO_write (h,
&f, sizeof(double)))
+#define GNUNET_BIO_write_double(h, f) GNUNET_BIO_write (h, &f, sizeof(double))
/**
Modified: gnunet/src/util/bio.c
===================================================================
--- gnunet/src/util/bio.c 2009-10-19 22:00:02 UTC (rev 9209)
+++ gnunet/src/util/bio.c 2009-10-19 22:28:37 UTC (rev 9210)
@@ -169,7 +169,7 @@
char *buf;
uint32_t big;
- if (! GNUNET_BIO_read_int32 (h, &big))
+ if (GNUNET_OK != GNUNET_BIO_read_int32 (h, &big))
return GNUNET_SYSERR;
if (big == 0)
{
@@ -187,7 +187,7 @@
}
buf = GNUNET_malloc (big);
buf[--big] = '\0';
- if (big != GNUNET_BIO_read (h, what, buf, big))
+ if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big))
{
GNUNET_free (buf);
return GNUNET_SYSERR;
@@ -227,7 +227,7 @@
return GNUNET_SYSERR;
}
buf = GNUNET_malloc (size);
- if (size !=
+ if (GNUNET_OK !=
GNUNET_BIO_read (h, what, buf, size))
{
GNUNET_free (buf);
@@ -262,7 +262,7 @@
{
int32_t big;
- if (sizeof (int32_t) !=
+ if (GNUNET_OK !=
GNUNET_BIO_read (h,
what,
&big,
@@ -287,7 +287,7 @@
{
int64_t big;
- if (sizeof (int64_t) !=
+ if (GNUNET_OK !=
GNUNET_BIO_read (h,
what,
&big,
@@ -342,6 +342,7 @@
*/
int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h)
{
+ ssize_t wrt;
int ret;
if (NULL == h->fd)
@@ -350,8 +351,12 @@
}
else
{
+ wrt = GNUNET_DISK_file_write (h->fd, h->buffer, h->have);
+ if (wrt == h->have)
+ ret = GNUNET_OK;
+ else
+ ret = GNUNET_SYSERR;
GNUNET_DISK_file_close (h->fd);
- ret = GNUNET_OK;
}
GNUNET_free (h);
return ret;
Modified: gnunet/src/util/test_bio.c
===================================================================
--- gnunet/src/util/test_bio.c 2009-10-19 22:00:02 UTC (rev 9209)
+++ gnunet/src/util/test_bio.c 2009-10-19 22:28:37 UTC (rev 9210)
@@ -34,10 +34,9 @@
main (int argc, char *argv[])
{
- char *readResultString;
+ char *readResultString;
int64_t testNumber = (int64_t)TESTNUMBER64;
-
- const char *writeString = TESTSTRING;
+ int64_t testNum;
char *msg;
char* fileName = GNUNET_DISK_mktemp ("gnunet_bio");
@@ -49,16 +48,15 @@
metaDataW = GNUNET_CONTAINER_meta_data_create();
GNUNET_CONTAINER_meta_data_add_publication_date(metaDataW);
fileW = GNUNET_BIO_write_open(fileName);
- GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_string(fileW,writeString));
+ GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_string(fileW, TESTSTRING));
GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_meta_data(fileW,metaDataW));
GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_int64(fileW,testNumber));
GNUNET_assert(GNUNET_OK == GNUNET_BIO_write_close(fileW));
fileR = GNUNET_BIO_read_open (fileName);
- GNUNET_BIO_read_meta_data(fileR,"Read meta error",&metaDataR);
- size_t readMaxLen = 200;
- //GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_string(fileR,"Read string
error",&readResultString,readMaxLen));
- //GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_int64__(fileR,"Read int64
error",&testNum));
- GNUNET_BIO_read_close(fileR,&msg);
+ GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_string(fileR, "Read string
error", &readResultString, 200));
+ GNUNET_BIO_read_meta_data(fileR, "Read meta error", &metaDataR);
+ GNUNET_assert(GNUNET_OK == GNUNET_BIO_read_int64(fileR, &testNum));
+ GNUNET_BIO_read_close(fileR,&msg);
GNUNET_CONTAINER_meta_data_destroy(metaDataW);
GNUNET_CONTAINER_meta_data_destroy(metaDataR);
free(fileName);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9210 - in gnunet/src: include util,
gnunet <=