gnunet_disk_lib.h | gnunet_disk_lib.h | |||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
Boston, MA 02111-1307, USA. | Boston, MA 02111-1307, USA. | |||
*/ | */ | |||
/** | /** | |||
* @file include/gnunet_disk_lib.h | * @file include/gnunet_disk_lib.h | |||
* @brief disk IO apis | * @brief disk IO apis | |||
*/ | */ | |||
#ifndef GNUNET_DISK_LIB_H | #ifndef GNUNET_DISK_LIB_H | |||
#define GNUNET_DISK_LIB_H | #define GNUNET_DISK_LIB_H | |||
/** | #if WINDOWS | |||
* Opaque handle used to access files. | #define OFF_T uint64_t | |||
*/ | #else | |||
struct GNUNET_DISK_FileHandle; | #define OFF_T off_t | |||
#endif | ||||
/** | /** | |||
* Handle used to manage a pipe. | * Handle used to manage a pipe. | |||
*/ | */ | |||
struct GNUNET_DISK_PipeHandle; | struct GNUNET_DISK_PipeHandle; | |||
enum GNUNET_FILE_Type | enum GNUNET_FILE_Type | |||
{ | { | |||
GNUNET_DISK_FILE, GNUNET_PIPE | GNUNET_DISK_FILE, GNUNET_PIPE | |||
}; | }; | |||
skipping to change at line 288 | skipping to change at line 289 | |||
int | int | |||
GNUNET_DISK_file_test (const char *fil); | GNUNET_DISK_file_test (const char *fil); | |||
/** | /** | |||
* Move the read/write pointer in a file | * Move the read/write pointer in a file | |||
* @param h handle of an open file | * @param h handle of an open file | |||
* @param offset position to move to | * @param offset position to move to | |||
* @param whence specification to which position the offset parameter relat es to | * @param whence specification to which position the offset parameter relat es to | |||
* @return the new position on success, GNUNET_SYSERR otherwise | * @return the new position on success, GNUNET_SYSERR otherwise | |||
*/ | */ | |||
off_t | OFF_T | |||
GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, OFF_T offset | |||
, | , | |||
enum GNUNET_DISK_Seek whence); | enum GNUNET_DISK_Seek whence); | |||
/** | /** | |||
* Get the size of the file (or directory) | * Get the size of the file (or directory) | |||
* of the given file (in bytes). | * of the given file (in bytes). | |||
* | * | |||
* @param filename name of the file or directory | * @param filename name of the file or directory | |||
* @param size set to the size of the file (or, | * @param size set to the size of the file (or, | |||
* in the case of directories, the sum | * in the case of directories, the sum | |||
* of all sizes of files in the directory) | * of all sizes of files in the directory) | |||
skipping to change at line 366 | skipping to change at line 367 | |||
/** | /** | |||
* Get the size of an open file. | * Get the size of an open file. | |||
* | * | |||
* @param fh open file handle | * @param fh open file handle | |||
* @param size where to write size of the file | * @param size where to write size of the file | |||
* @return GNUNET_OK on success, GNUNET_SYSERR on error | * @return GNUNET_OK on success, GNUNET_SYSERR on error | |||
*/ | */ | |||
int | int | |||
GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, | |||
off_t *size); | OFF_T *size); | |||
/** | /** | |||
* Creates an interprocess channel | * Creates an interprocess channel | |||
* @param blocking creates an asynchronous pipe if set to GNUNET_NO | * | |||
* @param blocking_read creates an asynchronous pipe for reading if set to | ||||
GNUNET_NO | ||||
* @param blocking_write creates an asynchronous pipe for writing if set to | ||||
GNUNET_NO | ||||
* @param inherit_read 1 to make read handle inheritable, 0 otherwise (NT o nly) | * @param inherit_read 1 to make read handle inheritable, 0 otherwise (NT o nly) | |||
* @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only) | * @param inherit_write 1 to make write handle inheritable, 0 otherwise (NT only) | |||
* @return handle to the new pipe, NULL on error | * @return handle to the new pipe, NULL on error | |||
*/ | */ | |||
struct GNUNET_DISK_PipeHandle * | struct GNUNET_DISK_PipeHandle * | |||
GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write); | GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, | |||
int inherit_write); | ||||
/** | ||||
* Creates a pipe object from a couple of file descriptors. | ||||
* Useful for wrapping existing pipe FDs. | ||||
* | ||||
* @param blocking_read creates an asynchronous pipe for reading if set to | ||||
GNUNET_NO | ||||
* @param blocking_write creates an asynchronous pipe for writing if set to | ||||
GNUNET_NO | ||||
* @param fd an array of two fd values. One of them may be -1 for read-only | ||||
or write-only pipes | ||||
* | ||||
* @return handle to the new pipe, NULL on error | ||||
*/ | ||||
struct GNUNET_DISK_PipeHandle * | ||||
GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]) | ||||
; | ||||
/** | /** | |||
* Closes an interprocess channel | * Closes an interprocess channel | |||
* @param p pipe | * @param p pipe | |||
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | |||
*/ | */ | |||
int | int | |||
GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); | |||
/** | /** | |||
skipping to change at line 430 | skipping to change at line 446 | |||
* @param result the buffer to write the result to | * @param result the buffer to write the result to | |||
* @param len the maximum number of bytes to read | * @param len the maximum number of bytes to read | |||
* @return the number of bytes read on success, GNUNET_SYSERR on failure | * @return the number of bytes read on success, GNUNET_SYSERR on failure | |||
*/ | */ | |||
ssize_t | ssize_t | |||
GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result , | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, void *result , | |||
size_t len); | size_t len); | |||
/** | /** | |||
* Read the contents of a binary file into a buffer. | * Read the contents of a binary file into a buffer. | |||
* Guarantees not to block (returns GNUNET_SYSERR and sets errno to EAGAIN | ||||
* when no data can be read). | ||||
* | ||||
* @param h handle to an open file | ||||
* @param result the buffer to write the result to | ||||
* @param len the maximum number of bytes to read | ||||
* @return the number of bytes read on success, GNUNET_SYSERR on failure | ||||
*/ | ||||
ssize_t | ||||
GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h | ||||
, | ||||
void *result, size_t len); | ||||
/** | ||||
* Read the contents of a binary file into a buffer. | ||||
* | * | |||
* @param fn file name | * @param fn file name | |||
* @param result the buffer to write the result to | * @param result the buffer to write the result to | |||
* @param len the maximum number of bytes to read | * @param len the maximum number of bytes to read | |||
* @return number of bytes read, GNUNET_SYSERR on failure | * @return number of bytes read, GNUNET_SYSERR on failure | |||
*/ | */ | |||
ssize_t | ssize_t | |||
GNUNET_DISK_fn_read (const char *fn, void *result, size_t len); | GNUNET_DISK_fn_read (const char *fn, void *result, size_t len); | |||
/** | /** | |||
skipping to change at line 452 | skipping to change at line 482 | |||
* @param h handle to open file | * @param h handle to open file | |||
* @param buffer the data to write | * @param buffer the data to write | |||
* @param n number of bytes to write | * @param n number of bytes to write | |||
* @return number of bytes written on success, GNUNET_SYSERR on error | * @return number of bytes written on success, GNUNET_SYSERR on error | |||
*/ | */ | |||
ssize_t | ssize_t | |||
GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, | GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, | |||
const void *buffer, size_t n); | const void *buffer, size_t n); | |||
/** | /** | |||
* Write a buffer to a file, blocking, if necessary. | ||||
* @param h handle to open file | ||||
* @param buffer the data to write | ||||
* @param n number of bytes to write | ||||
* @return number of bytes written on success, GNUNET_SYSERR on error | ||||
*/ | ||||
ssize_t | ||||
GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle * h, | ||||
const void *buffer, size_t n); | ||||
/** | ||||
* Write a buffer to a file. If the file is longer than | * Write a buffer to a file. If the file is longer than | |||
* the given buffer size, it will be truncated. | * the given buffer size, it will be truncated. | |||
* | * | |||
* @param fn file name | * @param fn file name | |||
* @param buffer the data to write | * @param buffer the data to write | |||
* @param n number of bytes to write | * @param n number of bytes to write | |||
* @param mode file permissions | * @param mode file permissions | |||
* @return number of bytes written on success, GNUNET_SYSERR on error | * @return number of bytes written on success, GNUNET_SYSERR on error | |||
*/ | */ | |||
ssize_t | ssize_t | |||
skipping to change at line 535 | skipping to change at line 576 | |||
/** | /** | |||
* Scan a directory for files using the scheduler to run a task for | * Scan a directory for files using the scheduler to run a task for | |||
* each entry. The name of the directory must be expanded first (!). | * each entry. The name of the directory must be expanded first (!). | |||
* If a scheduler does not need to be used, GNUNET_DISK_directory_scan | * If a scheduler does not need to be used, GNUNET_DISK_directory_scan | |||
* may provide a simpler API. | * may provide a simpler API. | |||
* | * | |||
* @param prio priority to use | * @param prio priority to use | |||
* @param dirName the name of the directory | * @param dirName the name of the directory | |||
* @param callback the method to call for each file | * @param callback the method to call for each file | |||
* @param callback_cls closure for callback | * @param callback_cls closure for callback | |||
* @return GNUNET_YES if directory is not empty and 'callback' | ||||
* will be called later, GNUNET_NO otherwise, GNUNET_SYSERR on erro | ||||
r. | ||||
*/ | */ | |||
void | int | |||
GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, | GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio, | |||
const char *dirName, | const char *dirName, | |||
GNUNET_DISK_DirectoryIteratorCallback | GNUNET_DISK_DirectoryIteratorCallback | |||
callback, void *callback_cls); | callback, void *callback_cls); | |||
/** | /** | |||
* Create the directory structure for storing | * Create the directory structure for storing | |||
* a file. | * a file. | |||
* | * | |||
* @param filename name of a file in the directory | * @param filename name of a file in the directory | |||
skipping to change at line 595 | skipping to change at line 638 | |||
/** | /** | |||
* Lock a part of a file. | * Lock a part of a file. | |||
* | * | |||
* @param fh file handle | * @param fh file handle | |||
* @param lockStart absolute position from where to lock | * @param lockStart absolute position from where to lock | |||
* @param lockEnd absolute position until where to lock | * @param lockEnd absolute position until where to lock | |||
* @param excl GNUNET_YES for an exclusive lock | * @param excl GNUNET_YES for an exclusive lock | |||
* @return GNUNET_OK on success, GNUNET_SYSERR on error | * @return GNUNET_OK on success, GNUNET_SYSERR on error | |||
*/ | */ | |||
int | int | |||
GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, OFF_T lockStart, | |||
off_t lockEnd, int excl); | OFF_T lockEnd, int excl); | |||
/** | /** | |||
* Unlock a part of a file | * Unlock a part of a file | |||
* @param fh file handle | * @param fh file handle | |||
* @param unlockStart absolute position from where to unlock | * @param unlockStart absolute position from where to unlock | |||
* @param unlockEnd absolute position until where to unlock | * @param unlockEnd absolute position until where to unlock | |||
* @return GNUNET_OK on success, GNUNET_SYSERR on error | * @return GNUNET_OK on success, GNUNET_SYSERR on error | |||
*/ | */ | |||
int | int | |||
GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockSta | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, OFF_T unlockSta | |||
rt, | rt, | |||
off_t unlockEnd); | OFF_T unlockEnd); | |||
/** | /** | |||
* @brief Removes special characters as ':' from a filename. | * @brief Removes special characters as ':' from a filename. | |||
* @param fn the filename to canonicalize | * @param fn the filename to canonicalize | |||
*/ | */ | |||
void | void | |||
GNUNET_DISK_filename_canonicalize (char *fn); | GNUNET_DISK_filename_canonicalize (char *fn); | |||
/** | /** | |||
* @brief Change owner of a file | * @brief Change owner of a file | |||
skipping to change at line 678 | skipping to change at line 721 | |||
GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); | |||
/** | /** | |||
* Write file changes to disk | * Write file changes to disk | |||
* @param h handle to an open file | * @param h handle to an open file | |||
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise | * @return GNUNET_OK on success, GNUNET_SYSERR otherwise | |||
*/ | */ | |||
int | int | |||
GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); | |||
/** | ||||
* Creates a named pipe/FIFO and opens it | ||||
* @param fn pointer to the name of the named pipe or to NULL | ||||
* @param flags open flags | ||||
* @param perm access permissions | ||||
* @return pipe handle on success, NULL on error | ||||
*/ | ||||
struct GNUNET_DISK_FileHandle * | ||||
GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags, | ||||
enum GNUNET_DISK_AccessPermissions perm); | ||||
/** | ||||
* Opens already existing named pipe/FIFO | ||||
* | ||||
* @param fn name of an existing named pipe | ||||
* @param flags open flags | ||||
* @param perm access permissions | ||||
* @return pipe handle on success, NULL on error | ||||
*/ | ||||
struct GNUNET_DISK_FileHandle * | ||||
GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, | ||||
enum GNUNET_DISK_AccessPermissions perm); | ||||
/** | ||||
* Closes a named pipe/FIFO | ||||
* @param pipe named pipe | ||||
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise | ||||
*/ | ||||
int | ||||
GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe); | ||||
#if 0 /* keep Emacsens' auto-indent happy */ | #if 0 /* keep Emacsens' auto-indent happy */ | |||
{ | { | |||
#endif | #endif | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
/* ifndef GNUNET_DISK_LIB_H */ | /* ifndef GNUNET_DISK_LIB_H */ | |||
#endif | #endif | |||
/* end of gnunet_disk_lib.h */ | /* end of gnunet_disk_lib.h */ | |||
End of changes. 12 change blocks. | ||||
47 lines changed or deleted | 68 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |