diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-09-13 19:46:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-09-13 19:46:45 +0000 |
commit | e5ba359af49fac05185f5ec0b4dbb47c7060167a (patch) | |
tree | c8146873eb3676714f2c370c067f5b7164146918 /src/util/bio.c | |
parent | ae202e69cb8d882992cac472a2fd86da0d0b18bf (diff) | |
download | gnunet-e5ba359af49fac05185f5ec0b4dbb47c7060167a.tar.gz gnunet-e5ba359af49fac05185f5ec0b4dbb47c7060167a.zip |
-fixing resuming publish operation
Diffstat (limited to 'src/util/bio.c')
-rw-r--r-- | src/util/bio.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/util/bio.c b/src/util/bio.c index dd2a182b1..b4f33f589 100644 --- a/src/util/bio.c +++ b/src/util/bio.c | |||
@@ -75,7 +75,7 @@ GNUNET_BIO_read_open (const char *fn) | |||
75 | * | 75 | * |
76 | * @param h file handle | 76 | * @param h file handle |
77 | * @param emsg set to the error message | 77 | * @param emsg set to the error message |
78 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 78 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
79 | */ | 79 | */ |
80 | int | 80 | int |
81 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) | 81 | GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) |
@@ -100,7 +100,7 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) | |||
100 | * @param what describes what is being read (for error message creation) | 100 | * @param what describes what is being read (for error message creation) |
101 | * @param result the buffer to write the result to | 101 | * @param result the buffer to write the result to |
102 | * @param len the number of bytes to read | 102 | * @param len the number of bytes to read |
103 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 103 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
104 | */ | 104 | */ |
105 | int | 105 | int |
106 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, | 106 | GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, |
@@ -111,7 +111,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
111 | size_t pos; | 111 | size_t pos; |
112 | ssize_t ret; | 112 | ssize_t ret; |
113 | 113 | ||
114 | if (h->emsg != NULL) | 114 | if (NULL != h->emsg) |
115 | return GNUNET_SYSERR; | 115 | return GNUNET_SYSERR; |
116 | pos = 0; | 116 | pos = 0; |
117 | do | 117 | do |
@@ -131,15 +131,19 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
131 | GNUNET_assert (h->have == h->pos); | 131 | GNUNET_assert (h->have == h->pos); |
132 | /* fill buffer */ | 132 | /* fill buffer */ |
133 | ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size); | 133 | ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size); |
134 | if (ret == -1) | 134 | if (-1 == ret) |
135 | { | 135 | { |
136 | GNUNET_asprintf (&h->emsg, _("Error reading `%s': %s"), what, | 136 | GNUNET_asprintf (&h->emsg, |
137 | _("Error reading `%s': %s"), | ||
138 | what, | ||
137 | STRERROR (errno)); | 139 | STRERROR (errno)); |
138 | return GNUNET_SYSERR; | 140 | return GNUNET_SYSERR; |
139 | } | 141 | } |
140 | if (ret == 0) | 142 | if (0 == ret) |
141 | { | 143 | { |
142 | GNUNET_asprintf (&h->emsg, _("Error reading `%s': %s"), what, | 144 | GNUNET_asprintf (&h->emsg, |
145 | _("Error reading `%s': %s"), | ||
146 | what, | ||
143 | _("End of file")); | 147 | _("End of file")); |
144 | return GNUNET_SYSERR; | 148 | return GNUNET_SYSERR; |
145 | } | 149 | } |
@@ -159,7 +163,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
159 | * @param line line number in the source file | 163 | * @param line line number in the source file |
160 | * @param result the buffer to write the result to | 164 | * @param result the buffer to write the result to |
161 | * @param len the number of bytes to read | 165 | * @param len the number of bytes to read |
162 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 166 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
163 | */ | 167 | */ |
164 | int | 168 | int |
165 | GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, const char *file, int line, | 169 | GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, const char *file, int line, |
@@ -180,7 +184,7 @@ GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, const char *file, int line, | |||
180 | * @param result the buffer to store a pointer to the (allocated) string to | 184 | * @param result the buffer to store a pointer to the (allocated) string to |
181 | * (note that *result could be set to NULL as well) | 185 | * (note that *result could be set to NULL as well) |
182 | * @param maxLen maximum allowed length for the string | 186 | * @param maxLen maximum allowed length for the string |
183 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 187 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
184 | */ | 188 | */ |
185 | int | 189 | int |
186 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | 190 | GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, |
@@ -195,7 +199,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
195 | GNUNET_asprintf (&h->emsg, _("Error reading length of string `%s'"), what); | 199 | GNUNET_asprintf (&h->emsg, _("Error reading length of string `%s'"), what); |
196 | return GNUNET_SYSERR; | 200 | return GNUNET_SYSERR; |
197 | } | 201 | } |
198 | if (big == 0) | 202 | if (0 == big) |
199 | { | 203 | { |
200 | *result = NULL; | 204 | *result = NULL; |
201 | return GNUNET_OK; | 205 | return GNUNET_OK; |
@@ -209,7 +213,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
209 | buf = GNUNET_malloc (big); | 213 | buf = GNUNET_malloc (big); |
210 | *result = buf; | 214 | *result = buf; |
211 | buf[--big] = '\0'; | 215 | buf[--big] = '\0'; |
212 | if (big == 0) | 216 | if (0 == big) |
213 | return GNUNET_OK; | 217 | return GNUNET_OK; |
214 | if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big)) | 218 | if (GNUNET_OK != GNUNET_BIO_read (h, what, buf, big)) |
215 | { | 219 | { |
@@ -227,7 +231,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
227 | * @param h handle to an open file | 231 | * @param h handle to an open file |
228 | * @param what describes what is being read (for error message creation) | 232 | * @param what describes what is being read (for error message creation) |
229 | * @param result the buffer to store a pointer to the (allocated) metadata | 233 | * @param result the buffer to store a pointer to the (allocated) metadata |
230 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 234 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
231 | */ | 235 | */ |
232 | int | 236 | int |
233 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, | 237 | GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, |
@@ -277,7 +281,7 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, | |||
277 | * @param file name of the source file | 281 | * @param file name of the source file |
278 | * @param line line number in the source file | 282 | * @param line line number in the source file |
279 | * @param i address of 32-bit integer to read | 283 | * @param i address of 32-bit integer to read |
280 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 284 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
281 | */ | 285 | */ |
282 | int | 286 | int |
283 | GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, | 287 | GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, |
@@ -299,7 +303,7 @@ GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, | |||
299 | * @param file name of the source file | 303 | * @param file name of the source file |
300 | * @param line line number in the source file | 304 | * @param line line number in the source file |
301 | * @param i address of 64-bit integer to read | 305 | * @param i address of 64-bit integer to read |
302 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 306 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
303 | */ | 307 | */ |
304 | int | 308 | int |
305 | GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file, | 309 | GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file, |
@@ -357,7 +361,7 @@ GNUNET_BIO_write_open (const char *fn) | |||
357 | * Close an open file for writing. | 361 | * Close an open file for writing. |
358 | * | 362 | * |
359 | * @param h file handle | 363 | * @param h file handle |
360 | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | 364 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
361 | */ | 365 | */ |
362 | int | 366 | int |
363 | GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h) | 367 | GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h) |
@@ -376,7 +380,7 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h) | |||
376 | * Force a buffered writer to flush its buffer | 380 | * Force a buffered writer to flush its buffer |
377 | * | 381 | * |
378 | * @param h the writer handle | 382 | * @param h the writer handle |
379 | * @return GNUNET_OK upon success. Upon failure GNUNET_SYSERR is returned and | 383 | * @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned and |
380 | * the file is closed | 384 | * the file is closed |
381 | */ | 385 | */ |
382 | int | 386 | int |
@@ -402,7 +406,7 @@ GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h) | |||
402 | * @param h handle to open file | 406 | * @param h handle to open file |
403 | * @param buffer the data to write | 407 | * @param buffer the data to write |
404 | * @param n number of bytes to write | 408 | * @param n number of bytes to write |
405 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 409 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
406 | */ | 410 | */ |
407 | int | 411 | int |
408 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, | 412 | GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, |
@@ -441,10 +445,11 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, | |||
441 | * | 445 | * |
442 | * @param h handle to open file | 446 | * @param h handle to open file |
443 | * @param s string to write (can be NULL) | 447 | * @param s string to write (can be NULL) |
444 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 448 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
445 | */ | 449 | */ |
446 | int | 450 | int |
447 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s) | 451 | GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, |
452 | const char *s) | ||
448 | { | 453 | { |
449 | uint32_t slen; | 454 | uint32_t slen; |
450 | 455 | ||
@@ -462,7 +467,7 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s) | |||
462 | * | 467 | * |
463 | * @param h handle to open file | 468 | * @param h handle to open file |
464 | * @param m metadata to write | 469 | * @param m metadata to write |
465 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 470 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
466 | */ | 471 | */ |
467 | int | 472 | int |
468 | GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, | 473 | GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, |