aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-08-24 09:26:47 +0000
committerChristian Grothoff <christian@grothoff.org>2009-08-24 09:26:47 +0000
commitda7cc55488f90b3294dbb7aa186184e6e8501d7e (patch)
tree642f70be79ca8f2cbdbb3579d213086f3a25a4bf /src/include
parent2518cfc0a86865ebe4d0550e0013ed52a494231b (diff)
downloadgnunet-da7cc55488f90b3294dbb7aa186184e6e8501d7e.tar.gz
gnunet-da7cc55488f90b3294dbb7aa186184e6e8501d7e.zip
hxing
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/gnunet_bio_lib.h281
-rw-r--r--src/include/gnunet_disk_lib.h10
-rw-r--r--src/include/gnunet_fs_service.h32
-rw-r--r--src/include/gnunet_util_lib.h1
5 files changed, 321 insertions, 4 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 69954fd30..008d6a180 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -13,6 +13,7 @@ nodist_gnunetinclude_HEADERS = \
13 13
14gnunetinclude_HEADERS = \ 14gnunetinclude_HEADERS = \
15 gnunet_arm_service.h \ 15 gnunet_arm_service.h \
16 gnunet_bio_lib.h \
16 gnunet_client_lib.h \ 17 gnunet_client_lib.h \
17 gnunet_common.h \ 18 gnunet_common.h \
18 gnunet_constants.h \ 19 gnunet_constants.h \
diff --git a/src/include/gnunet_bio_lib.h b/src/include/gnunet_bio_lib.h
new file mode 100644
index 000000000..02b04570e
--- /dev/null
+++ b/src/include/gnunet_bio_lib.h
@@ -0,0 +1,281 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file include/gnunet_bio_lib.h
23 * @brief buffered IO API
24 * @author Christian Grothoff
25 */
26
27#ifndef GNUNET_BIO_LIB_H
28#define GNUNET_BIO_LIB_H
29
30#include "gnunet_container_lib.h"
31
32#ifdef __cplusplus
33extern "C"
34{
35#if 0 /* keep Emacsens' auto-indent happy */
36}
37#endif
38#endif
39
40/**
41 * Handle for buffered reading.
42 */
43struct GNUNET_BIO_ReadHandle;
44
45
46/**
47 * Open a file for reading.
48 *
49 * @param fn file name to be opened
50 * @return IO handle on success, NULL on error
51 */
52struct GNUNET_BIO_ReadHandle *GNUNET_BIO_read_open (const char *fn);
53
54
55/**
56 * Close an open file. Reports if any errors reading
57 * from the file were encountered.
58 *
59 * @param h file handle
60 * @param emsg set to the error message
61 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
62 */
63int GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h,
64 char **emsg);
65
66
67/**
68 * Read the contents of a binary file into a buffer.
69 *
70 * @param h handle to an open file
71 * @param what describes what is being read (for error message creation)
72 * @param result the buffer to write the result to
73 * @param len the number of bytes to read
74 * @return len on success, GNUNET_SYSERR on failure
75 */
76ssize_t GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
77 const char *what,
78 void *result,
79 size_t len);
80
81/**
82 * Read 0-terminated string from a file.
83 *
84 * @param h handle to an open file
85 * @param what describes what is being read (for error message creation)
86 * @param result the buffer to store a pointer to the (allocated) string to
87 * (note that *result could be set to NULL as well)
88 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
89 */
90int GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
91 const char *what,
92 char **result);
93
94
95/**
96 * Read metadata container from a file.
97 *
98 * @param h handle to an open file
99 * @param what describes what is being read (for error message creation)
100 * @param result the buffer to store a pointer to the (allocated) metadata
101 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
102 */
103int GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h,
104 const char *what,
105 struct GNUNET_CONTAINER_MetaData **result);
106
107
108/**
109 * Read a float.
110 *
111 * @param h hande to open file
112 * @param f address of float to read
113 */
114#define GNUNET_BIO_read_float(h, f) (sizeof(float) == GNUNET_BIO_read (h, __FILE__ "##__LINE__##", f, sizeof(float)))
115
116
117
118/**
119 * Read a double.
120 *
121 * @param h hande to open file
122 * @param f address of double to read
123 */
124#define GNUNET_BIO_read_double(h, f) (sizeof(double) == GNUNET_BIO_read (h, __FILE__ "##__LINE__##", f, sizeof(double)))
125
126
127/**
128 * Read an (u)int32_t.
129 *
130 * @param h hande to open file
131 * @param what describes what is being read (for error message creation)
132 * @param i address of 32-bit integer to read
133 * @return GNUNET_OK on success, GNUNET_SYSERR on error
134 */
135int GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h,
136 const char *what,
137 int32_t *i);
138
139
140/**
141 * Read an (u)int32_t.
142 *
143 * @param h hande to open file
144 * @param i address of 32-bit integer to read
145 */
146#define GNUNET_BIO_read_int32(h, i) GNUNET_BIO_read_int32__ (h, __FILE__ "##__LINE__##", (int32_t*) i)
147
148
149/**
150 * Read an (u)int64_t.
151 *
152 * @param h hande to open file
153 * @param what describes what is being read (for error message creation)
154 * @param i address of 64-bit integer to read
155 * @return GNUNET_OK on success, GNUNET_SYSERR on error
156 */
157int GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h,
158 const char *what,
159 int64_t *i);
160
161
162/**
163 * Read an (u)int64_t.
164 *
165 * @param h hande to open file
166 * @param i address of 64-bit integer to read
167 */
168#define GNUNET_BIO_read_int64(h, i) (sizeof(int64_t) == GNUNET_BIO_read (h, __FILE__ "##__LINE__##", (int64_t*) i, sizeof(int64_t)))
169
170
171/**
172 * Handle for buffered writing.
173 */
174struct GNUNET_BIO_WriteHandle;
175/**
176 * Open a file for writing.
177 *
178 * @param fn file name to be opened
179 * @return IO handle on success, NULL on error
180 */
181struct GNUNET_BIO_WriteHandle *GNUNET_BIO_write_open (const char *fn);
182
183
184/**
185 * Close an open file for writing.
186 *
187 * @param h file handle
188 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
189 */
190int GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h);
191
192
193/**
194 * Write a buffer to a file.
195 *
196 * @param h handle to open file
197 * @param buffer the data to write
198 * @param n number of bytes to write
199 * @return GNUNET_OK on success, GNUNET_SYSERR on error
200 */
201ssize_t GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h,
202 const void *buffer,
203 size_t n);
204
205
206/**
207 * Write a string to a file.
208 *
209 * @param h handle to open file
210 * @param s string to write (can be NULL)
211 * @return GNUNET_OK on success, GNUNET_SYSERR on error
212 */
213int GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
214 const char *s);
215
216
217
218
219/**
220 * Write metadata container to a file.
221 *
222 * @param h handle to open file
223 * @param m metadata to write
224 * @return GNUNET_OK on success, GNUNET_SYSERR on error
225 */
226int GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h,
227 const struct GNUNET_CONTAINER_MetaData *m);
228
229
230
231/**
232 * Write a float.
233 *
234 * @param h hande to open file
235 * @param f float to write (must be a variable)
236 */
237#define GNUNET_BIO_write_float(h, f) (sizeof(float) == GNUNET_BIO_write (h, &f, sizeof(float)))
238
239
240
241/**
242 * Write a double.
243 *
244 * @param h hande to open file
245 * @param f double to write (must be a variable)
246 */
247#define GNUNET_BIO_write_float(h, f) (sizeof(double) == GNUNET_BIO_write (h, &f, sizeof(double)))
248
249
250/**
251 * Write an (u)int32_t.
252 *
253 * @param h hande to open file
254 * @param i address of 32-bit integer to write
255 * @return GNUNET_OK on success, GNUNET_SYSERR on error
256 */
257int GNUNET_BIO_write_int32 (struct GNUNET_BIO_ReadHandle *h,
258 int32_t i);
259
260
261/**
262 * Write an (u)int64_t.
263 *
264 * @param h hande to open file
265 * @param i address of 64-bit integer to write
266 * @return GNUNET_OK on success, GNUNET_SYSERR on error
267 */
268int GNUNET_BIO_write_int64 (struct GNUNET_BIO_ReadHandle *h,
269 int64_t i);
270
271
272#if 0 /* keep Emacsens' auto-indent happy */
273{
274#endif
275#ifdef __cplusplus
276}
277#endif
278
279/* ifndef GNUNET_BIO_LIB_H */
280#endif
281/* end of gnunet_bio_lib.h */
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index a5f279f05..f4fd6f36b 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -72,7 +72,12 @@ extern "C"
72#define GNUNET_DISK_PERM_OTHER_WRITE 128 72#define GNUNET_DISK_PERM_OTHER_WRITE 128
73#define GNUNET_DISK_PERM_OTHER_EXEC 256 73#define GNUNET_DISK_PERM_OTHER_EXEC 256
74 74
75enum GNUNET_DISK_Seek {GNUNET_SEEK_SET, GNUNET_SEEK_CUR, GNUNET_SEEK_END}; 75enum GNUNET_DISK_Seek
76 {
77 GNUNET_DISK_SEEK_SET,
78 GNUNET_DISK_SEEK_CUR,
79 GNUNET_DISK_SEEK_END
80 };
76 81
77struct GNUNET_DISK_FileHandle; 82struct GNUNET_DISK_FileHandle;
78 83
@@ -250,7 +255,8 @@ int GNUNET_DISK_file_copy (const char *src, const char *dst);
250 * @return the number of files found, -1 on error 255 * @return the number of files found, -1 on error
251 */ 256 */
252int GNUNET_DISK_directory_scan (const char *dirName, 257int GNUNET_DISK_directory_scan (const char *dirName,
253 GNUNET_FileNameCallback callback, void *data); 258 GNUNET_FileNameCallback callback,
259 void *data);
254 260
255 261
256/** 262/**
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 236bdd083..45cd1e77e 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -1418,6 +1418,8 @@ typedef int (*GNUNET_FS_FileInformationProcessor)(void *cls,
1418 * Create an entry for a file in a publish-structure. 1418 * Create an entry for a file in a publish-structure.
1419 * 1419 *
1420 * @param filename name of the file or directory to publish 1420 * @param filename name of the file or directory to publish
1421 * @param keywords under which keywords should this file be available
1422 * directly; can be NULL
1421 * @param meta metadata for the file 1423 * @param meta metadata for the file
1422 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, 1424 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1423 * GNUNET_SYSERR for simulation 1425 * GNUNET_SYSERR for simulation
@@ -1431,6 +1433,7 @@ typedef int (*GNUNET_FS_FileInformationProcessor)(void *cls,
1431struct GNUNET_FS_FileInformation * 1433struct GNUNET_FS_FileInformation *
1432GNUNET_FS_file_information_create_from_file (void *client_info, 1434GNUNET_FS_file_information_create_from_file (void *client_info,
1433 const char *filename, 1435 const char *filename,
1436 const struct GNUNET_FS_Uri *keywords,
1434 const struct GNUNET_CONTAINER_MetaData *meta, 1437 const struct GNUNET_CONTAINER_MetaData *meta,
1435 int do_index, 1438 int do_index,
1436 unsigned int anonymity, 1439 unsigned int anonymity,
@@ -1444,6 +1447,8 @@ GNUNET_FS_file_information_create_from_file (void *client_info,
1444 * @param length length of the file 1447 * @param length length of the file
1445 * @param data data for the file (should not be used afterwards by 1448 * @param data data for the file (should not be used afterwards by
1446 * the caller; caller will "free") 1449 * the caller; caller will "free")
1450 * @param keywords under which keywords should this file be available
1451 * directly; can be NULL
1447 * @param meta metadata for the file 1452 * @param meta metadata for the file
1448 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, 1453 * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
1449 * GNUNET_SYSERR for simulation 1454 * GNUNET_SYSERR for simulation
@@ -1458,6 +1463,7 @@ struct GNUNET_FS_FileInformation *
1458GNUNET_FS_file_information_create_from_data (void *client_info, 1463GNUNET_FS_file_information_create_from_data (void *client_info,
1459 uint64_t length, 1464 uint64_t length,
1460 void *data, 1465 void *data,
1466 const struct GNUNET_FS_Uri *keywords,
1461 const struct GNUNET_CONTAINER_MetaData *meta, 1467 const struct GNUNET_CONTAINER_MetaData *meta,
1462 int do_index, 1468 int do_index,
1463 unsigned int anonymity, 1469 unsigned int anonymity,
@@ -1539,6 +1545,10 @@ typedef void (*GNUNET_FS_FileProcessor)(void *cls,
1539 * 1545 *
1540 * @param cls closure 1546 * @param cls closure
1541 * @param dirname name of the directory to scan 1547 * @param dirname name of the directory to scan
1548 * @param do_index should files be indexed or inserted
1549 * @param anonymity desired anonymity level
1550 * @param priority priority for publishing
1551 * @param expirationTime expiration for publication
1542 * @param proc function to call on each entry 1552 * @param proc function to call on each entry
1543 * @param proc_cls closure for proc 1553 * @param proc_cls closure for proc
1544 * @param emsg where to store an error message (on errors) 1554 * @param emsg where to store an error message (on errors)
@@ -1546,6 +1556,10 @@ typedef void (*GNUNET_FS_FileProcessor)(void *cls,
1546 */ 1556 */
1547typedef int (*GNUNET_FS_DirectoryScanner)(void *cls, 1557typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1548 const char *dirname, 1558 const char *dirname,
1559 int do_index,
1560 unsigned int anonymity,
1561 unsigned int priority,
1562 struct GNUNET_TIME_Absolute expirationTime,
1549 GNUNET_FS_FileProcessor proc, 1563 GNUNET_FS_FileProcessor proc,
1550 void *proc_cls, 1564 void *proc_cls,
1551 char **emsg); 1565 char **emsg);
@@ -1565,6 +1579,10 @@ typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1565 * 1579 *
1566 * @param cls must be of type "struct EXTRACTOR_Extractor*" 1580 * @param cls must be of type "struct EXTRACTOR_Extractor*"
1567 * @param dirname name of the directory to scan 1581 * @param dirname name of the directory to scan
1582 * @param do_index should files be indexed or inserted
1583 * @param anonymity desired anonymity level
1584 * @param priority priority for publishing
1585 * @param expirationTime expiration for publication
1568 * @param proc function called on each entry 1586 * @param proc function called on each entry
1569 * @param proc_cls closure for proc 1587 * @param proc_cls closure for proc
1570 * @param emsg where to store an error message (on errors) 1588 * @param emsg where to store an error message (on errors)
@@ -1573,8 +1591,13 @@ typedef int (*GNUNET_FS_DirectoryScanner)(void *cls,
1573int 1591int
1574GNUNET_FS_directory_scanner_default (void *cls, 1592GNUNET_FS_directory_scanner_default (void *cls,
1575 const char *dirname, 1593 const char *dirname,
1594 int do_index,
1595 unsigned int anonymity,
1596 unsigned int priority,
1597 struct GNUNET_TIME_Absolute expirationTime,
1576 GNUNET_FS_FileProcessor proc, 1598 GNUNET_FS_FileProcessor proc,
1577 void *proc_cls); 1599 void *proc_cls,
1600 char **emsg);
1578 1601
1579 1602
1580/** 1603/**
@@ -1590,20 +1613,25 @@ GNUNET_FS_directory_scanner_default (void *cls,
1590 * @param filename name of the top-level file or directory 1613 * @param filename name of the top-level file or directory
1591 * @param scanner function used to get a list of files in a directory 1614 * @param scanner function used to get a list of files in a directory
1592 * @param scanner_cls closure for scanner 1615 * @param scanner_cls closure for scanner
1616 * @param do_index should files in the hierarchy be indexed?
1593 * @param anonymity what is the desired anonymity level for sharing? 1617 * @param anonymity what is the desired anonymity level for sharing?
1594 * @param priority what is the priority for OUR node to 1618 * @param priority what is the priority for OUR node to
1595 * keep this file available? Use 0 for maximum anonymity and 1619 * keep this file available? Use 0 for maximum anonymity and
1596 * minimum reliability... 1620 * minimum reliability...
1597 * @param expirationTime when should this content expire? 1621 * @param expirationTime when should this content expire?
1622 * @param emsg where to store an error message
1598 * @return publish structure entry for the directory, NULL on error 1623 * @return publish structure entry for the directory, NULL on error
1599 */ 1624 */
1600struct GNUNET_FS_FileInformation * 1625struct GNUNET_FS_FileInformation *
1601GNUNET_FS_file_information_create_from_directory (void *client_info, 1626GNUNET_FS_file_information_create_from_directory (void *client_info,
1627 const char *filename,
1602 GNUNET_FS_DirectoryScanner scanner, 1628 GNUNET_FS_DirectoryScanner scanner,
1603 void *scanner_cls, 1629 void *scanner_cls,
1630 int do_index,
1604 unsigned int anonymity, 1631 unsigned int anonymity,
1605 unsigned int priority, 1632 unsigned int priority,
1606 struct GNUNET_TIME_Absolute expirationTime); 1633 struct GNUNET_TIME_Absolute expirationTime,
1634 char **emsg);
1607 1635
1608 1636
1609/** 1637/**
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index fe382be3f..6bb87bf4d 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -37,6 +37,7 @@ extern "C"
37#endif 37#endif
38 38
39#include "gnunet_common.h" 39#include "gnunet_common.h"
40#include "gnunet_bio_lib.h"
40#include "gnunet_client_lib.h" 41#include "gnunet_client_lib.h"
41#include "gnunet_configuration_lib.h" 42#include "gnunet_configuration_lib.h"
42#include "gnunet_connection_lib.h" 43#include "gnunet_connection_lib.h"