[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10918 - gnunet/src/hostlist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10918 - gnunet/src/hostlist |
Date: |
Thu, 15 Apr 2010 16:42:45 +0200 |
Author: wachs
Date: 2010-04-15 16:42:45 +0200 (Thu, 15 Apr 2010)
New Revision: 10918
Modified:
gnunet/src/hostlist/hostlist-client.c
Log:
Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c 2010-04-15 14:40:14 UTC (rev
10917)
+++ gnunet/src/hostlist/hostlist-client.c 2010-04-15 14:42:45 UTC (rev
10918)
@@ -1025,14 +1025,24 @@
}
/* add code to read hostlists to file using bio */
- char * buffer = GNUNET_malloc (100 * sizeof (char));
- GNUNET_BIO_read_string (rh, NULL , &buffer, 100);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- ("Read from file %s : %s \n"), filename, buffer);
+ char *buffer = GNUNET_malloc (1000 * sizeof (char));
+ /* char *token;
- if ( GNUNET_OK != GNUNET_BIO_read_close ( rh , &buffer) )
+ while (GNUNET_OK == GNUNET_BIO_read_string (rh, NULL , &buffer, 1000) )
+ {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- ("Error while closing file %s\n"), filename);
+ ("Read from file %s : %s \n"), filename, buffer);
+
+ pch = strtok (str," ,.-");
+ while (pch != NULL)
+ {
+ printf ("%s\n",pch);
+ pch = strtok (NULL, " ,.-");
+ }
+
+ }
+ */
+ GNUNET_BIO_read_close ( rh , &buffer);
return GNUNET_OK;
}
@@ -1066,9 +1076,53 @@
}
/* add code to write hostlists to file using bio */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Writing hostlist to disk\n");
+ struct GNUNET_Hostlist * actual = dll_head;
+ struct GNUNET_Hostlist * next;
+ char * content = GNUNET_malloc(1000 * sizeof (char));
+ char * buffer = GNUNET_malloc(1000 * sizeof (char));
- /* iterate over all entries in dll */
+ actual = dll_head;
+ while ( GNUNET_YES)
+ {
+ /* serialize content */
+ /* uri;hello_count;quality; */
+ strcpy(content,actual->hostlist_uri);
+ strcat(content,";");
+ sprintf(buffer, "%lu", actual->hello_count);
+ strcat(content,buffer);
+ strcat(content,";");
+ sprintf(buffer, "%llu", (long long unsigned int) actual->quality);
+ strcat(content,buffer);
+ strcat(content,";");
+ sprintf(buffer, "%llu", (long long unsigned int)
actual->time_creation.value);
+ strcat(content,buffer);
+ strcat(content,";");
+ sprintf(buffer, "%llu", (long long unsigned int)
actual->time_last_usage.value);
+ strcat(content,buffer);
+ strcat(content,";");
+ sprintf(buffer, "%lu", actual->times_used);
+ strcat(content,buffer);
+ strcat(content,";");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ ("Content to write: %s\n"),
+ content);
+
+ GNUNET_BIO_write_string ( wh, content );
+
+
+ if (actual == dll_tail) break;
+ next = actual->next;
+ GNUNET_free (actual->hostlist_uri);
+ GNUNET_free (actual);
+ actual = next;
+ }
+ GNUNET_free (actual->hostlist_uri);
+ GNUNET_free (actual);
+ GNUNET_free (content);
+
if ( GNUNET_OK != GNUNET_BIO_write_close ( wh ) )
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
("Error while closing file %s\n"),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10918 - gnunet/src/hostlist,
gnunet <=