diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-05 13:42:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-05 13:42:16 +0000 |
commit | 1e64f59e503ca06b599f7eea3da62df9f78a4c5c (patch) | |
tree | 37bc1d15ce6b2e36bd52dda9d3ac60c890af8df7 /src/include/gnunet_bio_lib.h | |
parent | eb123f37892e3fd79a33f0375ab99a52dc4b6915 (diff) | |
download | gnunet-1e64f59e503ca06b599f7eea3da62df9f78a4c5c.tar.gz gnunet-1e64f59e503ca06b599f7eea3da62df9f78a4c5c.zip |
notes
Diffstat (limited to 'src/include/gnunet_bio_lib.h')
-rw-r--r-- | src/include/gnunet_bio_lib.h | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h index f70baa070..b11073765 100644 --- a/src/include/gnunet_bio_lib.h +++ b/src/include/gnunet_bio_lib.h | |||
@@ -78,6 +78,22 @@ int GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, | |||
78 | void *result, | 78 | void *result, |
79 | size_t len); | 79 | size_t len); |
80 | 80 | ||
81 | |||
82 | /** | ||
83 | * Read the contents of a binary file into a buffer. | ||
84 | * | ||
85 | * @param h handle to an open file | ||
86 | * @param file name of the source file | ||
87 | * @param line line number in the source file | ||
88 | * @param result the buffer to write the result to | ||
89 | * @param len the number of bytes to read | ||
90 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | ||
91 | */ | ||
92 | int GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, | ||
93 | const char *file, int line, | ||
94 | void *result, | ||
95 | size_t len); | ||
96 | |||
81 | /** | 97 | /** |
82 | * Read 0-terminated string from a file. | 98 | * Read 0-terminated string from a file. |
83 | * | 99 | * |
@@ -113,7 +129,7 @@ int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
113 | * @param h hande to open file | 129 | * @param h hande to open file |
114 | * @param f address of float to read | 130 | * @param f address of float to read |
115 | */ | 131 | */ |
116 | #define GNUNET_BIO_read_float(h, f) (GNUNET_BIO_read (h, __FILE__ "##__LINE__##", f, sizeof(float))) | 132 | #define GNUNET_BIO_read_float(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LINE__, f, sizeof(float))) |
117 | 133 | ||
118 | 134 | ||
119 | 135 | ||
@@ -123,7 +139,7 @@ int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
123 | * @param h hande to open file | 139 | * @param h hande to open file |
124 | * @param f address of double to read | 140 | * @param f address of double to read |
125 | */ | 141 | */ |
126 | #define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read (h, __FILE__ "##__LINE__##", f, sizeof(double))) | 142 | #define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LINE__, f, sizeof(double))) |
127 | 143 | ||
128 | 144 | ||
129 | /** | 145 | /** |
@@ -131,11 +147,12 @@ int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
131 | * | 147 | * |
132 | * @param h hande to open file | 148 | * @param h hande to open file |
133 | * @param what describes what is being read (for error message creation) | 149 | * @param what describes what is being read (for error message creation) |
150 | * @param line line number in the code | ||
134 | * @param i address of 32-bit integer to read | 151 | * @param i address of 32-bit integer to read |
135 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 152 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
136 | */ | 153 | */ |
137 | int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, | 154 | int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, |
138 | const char *what, | 155 | const char *what, int line, |
139 | int32_t *i); | 156 | int32_t *i); |
140 | 157 | ||
141 | 158 | ||
@@ -145,7 +162,7 @@ int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, | |||
145 | * @param h hande to open file | 162 | * @param h hande to open file |
146 | * @param i address of 32-bit integer to read | 163 | * @param i address of 32-bit integer to read |
147 | */ | 164 | */ |
148 | #define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__ "##__LINE__##", (int32_t*) i) | 165 | #define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__, __LINE__, (int32_t*) i) |
149 | 166 | ||
150 | 167 | ||
151 | /** | 168 | /** |
@@ -153,11 +170,12 @@ int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, | |||
153 | * | 170 | * |
154 | * @param h hande to open file | 171 | * @param h hande to open file |
155 | * @param what describes what is being read (for error message creation) | 172 | * @param what describes what is being read (for error message creation) |
173 | * @param line line number in the code | ||
156 | * @param i address of 64-bit integer to read | 174 | * @param i address of 64-bit integer to read |
157 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 175 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
158 | */ | 176 | */ |
159 | int GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, | 177 | int GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, |
160 | const char *what, | 178 | const char *what, int line, |
161 | int64_t *i); | 179 | int64_t *i); |
162 | 180 | ||
163 | 181 | ||
@@ -167,7 +185,7 @@ int GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, | |||
167 | * @param h hande to open file | 185 | * @param h hande to open file |
168 | * @param i address of 64-bit integer to read | 186 | * @param i address of 64-bit integer to read |
169 | */ | 187 | */ |
170 | #define GNUNET_BIO_read_int64(h, i) GNUNET_BIO_read_int64__ (h, __FILE__ "##__LINE__##", (int64_t*) i) | 188 | #define GNUNET_BIO_read_int64(h, i) GNUNET_BIO_read_int64__ (h, __FILE__, __LINE__, (int64_t*) i) |
171 | 189 | ||
172 | 190 | ||
173 | /** | 191 | /** |