aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_indexing.c
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2020-05-14 16:03:10 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-19 02:41:47 +0200
commitf4771fcc1c3fda21a46d0cb85d8b29e012254696 (patch)
tree012df74ed2cf44cb20605b239e1b88dab6edc645 /src/fs/gnunet-service-fs_indexing.c
parent6a52ce5f9bc35a852b215e7073f3a0d2665ca8de (diff)
downloadgnunet-f4771fcc1c3fda21a46d0cb85d8b29e012254696.tar.gz
gnunet-f4771fcc1c3fda21a46d0cb85d8b29e012254696.zip
Improved BIO API
BIO now supports reading from and writing to in-memory buffers. For reading, an allocated buffer (array) and a size is passed as arguments to the function opening the handle. For writing, a GNUNET_Buffer is created and used internally. The buffer contents can be extracted using the relevant function. There is a new API in addition to the existing read/write: this new API is more "declarative" in nature and is meant to mimic APIs like GNUNET_SQ. The read/write operations are defined in an array of specs which are then "commited" in a single (non-atomic) operation, rather than explicitly executing multiple function calls and checking their return value. Also there are small changes to GNUNET_Buffer to account for BIO's new features. Signed-off-by: Christian Grothoff <christian@grothoff.org>
Diffstat (limited to 'src/fs/gnunet-service-fs_indexing.c')
-rw-r--r--src/fs/gnunet-service-fs_indexing.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index 98fca3ec5..f4d560176 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -123,7 +123,7 @@ write_index_list ()
123 "INDEXDB"); 123 "INDEXDB");
124 return; 124 return;
125 } 125 }
126 wh = GNUNET_BIO_write_open (fn); 126 wh = GNUNET_BIO_write_open_file (fn);
127 if (NULL == wh) 127 if (NULL == wh)
128 { 128 {
129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 129 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -134,11 +134,14 @@ write_index_list ()
134 } 134 }
135 for (pos = indexed_files_head; NULL != pos; pos = pos->next) 135 for (pos = indexed_files_head; NULL != pos; pos = pos->next)
136 if ((GNUNET_OK != GNUNET_BIO_write (wh, 136 if ((GNUNET_OK != GNUNET_BIO_write (wh,
137 "fs-indexing-file-id",
137 &pos->file_id, 138 &pos->file_id,
138 sizeof(struct GNUNET_HashCode))) || 139 sizeof(struct GNUNET_HashCode))) ||
139 (GNUNET_OK != GNUNET_BIO_write_string (wh, pos->filename))) 140 (GNUNET_OK != GNUNET_BIO_write_string (wh,
141 "fs-indexing-filename",
142 pos->filename)))
140 break; 143 break;
141 if (GNUNET_OK != GNUNET_BIO_write_close (wh)) 144 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
142 { 145 {
143 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 146 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
144 _ ("Error writing `%s'.\n"), 147 _ ("Error writing `%s'.\n"),
@@ -178,7 +181,7 @@ read_index_list ()
178 GNUNET_free (fn); 181 GNUNET_free (fn);
179 return; 182 return;
180 } 183 }
181 rh = GNUNET_BIO_read_open (fn); 184 rh = GNUNET_BIO_read_open_file (fn);
182 if (NULL == rh) 185 if (NULL == rh)
183 { 186 {
184 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, 187 GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,