projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
service_new: ready_confirm_fd
[oweals/gnunet.git]
/
src
/
util
/
bio.c
diff --git
a/src/util/bio.c
b/src/util/bio.c
index 0a1c213f34f8649b519dd507ead5a5ae96c14835..62f4904f7d19367ab973161cbbaaf6e56551f045 100644
(file)
--- a/
src/util/bio.c
+++ b/
src/util/bio.c
@@
-1,6
+1,6
@@
/*
This file is part of GNUnet.
/*
This file is part of GNUnet.
- (C) 2006, 2009, 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2006, 2009, 2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@
-14,8
+14,8
@@
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
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., 5
9 Temple Place - Suite 330
,
- Boston, MA 0211
1-1307
, USA.
+ Free Software Foundation, Inc., 5
1 Franklin Street, Fifth Floor
,
+ Boston, MA 0211
0-1301
, USA.
*/
/**
* @file util/bio.c
*/
/**
* @file util/bio.c
@@
-23,14
+23,21
@@
* @author Christian Grothoff
*/
#include "platform.h"
* @author Christian Grothoff
*/
#include "platform.h"
-#include "gnunet_bio_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__)
#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__)
+#ifndef PATH_MAX
+/**
+ * Assumed maximum path length (for source file names).
+ */
+#define PATH_MAX 4096
+#endif
+
+
/**
* Size for I/O buffers.
/**
* Size for I/O buffers.
- */
+ */
#define BIO_BUFFER_SIZE 65536
/**
#define BIO_BUFFER_SIZE 65536
/**
@@
-135,7
+142,7
@@
GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
-GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
+GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
const char *what,
void *result, size_t len)
{
const char *what,
void *result, size_t len)
{
@@
-155,7
+162,7
@@
GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
{
if (min > len - pos)
min = len - pos;
{
if (min > len - pos)
min = len - pos;
- memcpy (&dst[pos], &h->buffer[h->pos], min);
+
GNUNET_
memcpy (&dst[pos], &h->buffer[h->pos], min);
h->pos += min;
pos += min;
}
h->pos += min;
pos += min;
}
@@
-175,7
+182,7
@@
GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
if (0 == ret)
{
GNUNET_asprintf (&h->emsg,
if (0 == ret)
{
GNUNET_asprintf (&h->emsg,
- _("Error reading `%s': %s"),
+ _("Error reading `%s': %s"),
what,
_("End of file"));
return GNUNET_SYSERR;
what,
_("End of file"));
return GNUNET_SYSERR;
@@
-199,13
+206,13
@@
GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
-GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
- const char *file,
+GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
+ const char *file,
int line,
int line,
- void *result,
+ void *result,
size_t len)
{
size_t len)
{
- char what[1024];
+ char what[
PATH_MAX +
1024];
GNUNET_snprintf (what, sizeof (what), "%s:%d", file, line);
return GNUNET_BIO_read (h, what, result, len);
GNUNET_snprintf (what, sizeof (what), "%s:%d", file, line);
return GNUNET_BIO_read (h, what, result, len);
@@
-225,7
+232,7
@@
GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
int
GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
const char *what,
int
GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
const char *what,
- char **result,
+ char **result,
size_t max_length)
{
char *buf;
size_t max_length)
{
char *buf;
@@
-272,7
+279,7
@@
GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
int
-GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
+GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
const char *what,
struct GNUNET_CONTAINER_MetaData **result)
{
const char *what,
struct GNUNET_CONTAINER_MetaData **result)
{
@@
-345,9
+352,9
@@
GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
-GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h,
+GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h,
const char *file,
const char *file,
- int line,
+ int line,
int64_t *i)
{
int64_t big;
int64_t *i)
{
int64_t big;
@@
-368,7
+375,7
@@
struct GNUNET_BIO_WriteHandle
* Underlying file handle.
*/
struct GNUNET_DISK_FileHandle *fd;
* Underlying file handle.
*/
struct GNUNET_DISK_FileHandle *fd;
-
+
/**
* I/O buffer. Do not free, allocated at the end of the struct.
*/
/**
* I/O buffer. Do not free, allocated at the end of the struct.
*/
@@
-481,7
+488,7
@@
GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer,
min = h->size - h->have;
if (min > n - pos)
min = n - pos;
min = h->size - h->have;
if (min > n - pos)
min = n - pos;
- memcpy (&h->buffer[h->have], &src[pos], min);
+
GNUNET_
memcpy (&h->buffer[h->have], &src[pos], min);
pos += min;
h->have += min;
if (pos == n)
pos += min;
h->have += min;
if (pos == n)
@@
-504,7
+511,7
@@
GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
-GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
+GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
const char *s)
{
uint32_t slen;
const char *s)
{
uint32_t slen;
@@
-562,7
+569,7
@@
GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
-GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
+GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
int32_t i)
{
int32_t big;
int32_t i)
{
int32_t big;
@@
-580,7
+587,7
@@
GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h,
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
-GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h,
+GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h,
int64_t i)
{
int64_t big;
int64_t i)
{
int64_t big;