GNUnet  0.11.x
gnunet_bio_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2009 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
32 #ifndef GNUNET_BIO_LIB_H
33 #define GNUNET_BIO_LIB_H
34 
35 #include "gnunet_container_lib.h"
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #if 0 /* keep Emacsens' auto-indent happy */
41 }
42 #endif
43 #endif
44 
49 
50 
57 struct GNUNET_BIO_ReadHandle *
58 GNUNET_BIO_read_open (const char *fn);
59 
60 
69 int
71 
72 
82 int
83 GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what,
84  void *result, size_t len);
85 
86 
97 int
99  const char *file, int line,
100  void *result, size_t len);
101 
112 int
113 GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what,
114  char **result, size_t max_length);
115 
116 
125 int
126 GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what,
128 
129 
136 #define GNUNET_BIO_read_float(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LINE__, \
137  f, sizeof(float)))
138 
139 
146 #define GNUNET_BIO_read_double(h, f) (GNUNET_BIO_read_fn (h, __FILE__, __LINE__, \
147  f, sizeof(double)))
148 
149 
159 int
160 GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
161  int line, int32_t *i);
162 
163 
170 #define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__, \
171  __LINE__, \
172  (int32_t*) i)
173 
174 
184 int
185 GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file,
186  int line, int64_t *i);
187 
188 
195 #define GNUNET_BIO_read_int64(h, i) GNUNET_BIO_read_int64__ (h, __FILE__, \
196  __LINE__, \
197  (int64_t*) i)
198 
199 
204 
211 struct GNUNET_BIO_WriteHandle *
212 GNUNET_BIO_write_open (const char *fn);
213 
214 
221 int
223 
224 
233 int
234 GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer,
235  size_t n);
236 
237 
245 int
247 
248 
256 int
257 GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h, const char *s);
258 
259 
267 int
269  const struct GNUNET_CONTAINER_MetaData *m);
270 
271 
278 #define GNUNET_BIO_write_float(h, f) GNUNET_BIO_write (h, &f, sizeof(float))
279 
280 
287 #define GNUNET_BIO_write_double(h, f) GNUNET_BIO_write (h, &f, sizeof(double))
288 
289 
297 int
298 GNUNET_BIO_write_int32 (struct GNUNET_BIO_WriteHandle *h, int32_t i);
299 
300 
308 int
309 GNUNET_BIO_write_int64 (struct GNUNET_BIO_WriteHandle *h, int64_t i);
310 
311 
312 #if 0 /* keep Emacsens' auto-indent happy */
313 {
314 #endif
315 #ifdef __cplusplus
316 }
317 #endif
318 
319 /* ifndef GNUNET_BIO_LIB_H */
320 #endif
321  /* end of group bio */
323 
324 /* end of gnunet_bio_lib.h */
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:544
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
int GNUNET_BIO_flush(struct GNUNET_BIO_WriteHandle *h)
Force a buffered writer to flush its buffer.
Definition: bio.c:458
int GNUNET_BIO_write_int64(struct GNUNET_BIO_WriteHandle *h, int64_t i)
Write an (u)int64_t.
Definition: bio.c:599
int GNUNET_BIO_read_int32__(struct GNUNET_BIO_ReadHandle *h, const char *file, int line, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:338
int GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open file.
Definition: bio.c:119
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open(const char *fn)
Open a file for reading.
Definition: bio.c:94
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
int GNUNET_BIO_read(struct GNUNET_BIO_ReadHandle *h, const char *what, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: bio.c:144
Meta data to associate with a file, directory or namespace.
static char * line
Desired phone line (string to be converted to a hash).
static char * fn
Filename of the unique file.
static int result
Global testing status.
char * buffer
I/O buffer.
Definition: bio.c:389
Handle for buffered writing.
Definition: bio.c:379
int GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string from a file.
Definition: bio.c:233
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
int GNUNET_BIO_read_fn(struct GNUNET_BIO_ReadHandle *h, const char *file, int line, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: bio.c:209
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open(const char *fn)
Open a file for writing.
Definition: bio.c:410
int GNUNET_BIO_read_int64__(struct GNUNET_BIO_ReadHandle *h, const char *file, int line, int64_t *i)
Read an (u)int64_t.
Definition: bio.c:362
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
int GNUNET_BIO_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
Read metadata container from a file.
Definition: bio.c:285
int GNUNET_BIO_write(struct GNUNET_BIO_WriteHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: bio.c:483
char * emsg
Error message, NULL if there were no errors.
Definition: bio.c:63
Handle for buffered reading.
Definition: bio.c:53
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...