fixing leak
[oweals/gnunet.git] / src / include / gnunet_disk_lib.h
index fc5b9b5eba58cfcc561922cd957a8e66fd5fb781..383a9daa2defbc706fec0d7cc750172abcf71c64 100644 (file)
@@ -288,12 +288,15 @@ int GNUNET_DISK_file_size (const char *filename,
  * @return GNUNET_OK on success
  */
 int GNUNET_DISK_file_get_identifiers (const char *filename,
-                                     uint32_t *dev,
+                                     uint64_t *dev,
                                      uint64_t *ino);
  
 
 /**
- * Create an (empty) temporary file on disk.
+ * Create an (empty) temporary file on disk.  If the given name is not
+ * an absolute path, the current 'TMPDIR' will be prepended.  In any case,
+ * 6 random characters will be appended to the name to create a unique
+ * filename.
  * 
  * @param t component to use for the name;
  *        does NOT contain "XXXXXX" or "/tmp/".
@@ -312,7 +315,7 @@ GNUNET_DISK_mktemp (const char *t);
  * @param fn file name to be opened
  * @param flags opening flags, a combination of GNUNET_DISK_OPEN_xxx bit flags
  * @param perm permissions for the newly created file, use
- *             GNUNET_DISK_PERM_USER_NONE if a file could not be created by this
+ *             GNUNET_DISK_PERM_NONE if a file could not be created by this
  *             call (because of flags)
  * @return IO handle on success, NULL on error
  */
@@ -323,9 +326,13 @@ struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn,
 /**
  * Creates an interprocess channel
  * @param blocking creates an asynchronous pipe if set to GNUNET_NO
+ * @param inherit_read 1 to make read 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
  */
-struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking);
+struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking,
+                                                int inherit_read,
+                                                int inherit_write);
 
 
 /**
@@ -335,6 +342,16 @@ struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking);
  */
 int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
 
+/**
+ * Closes one half of an interprocess channel
+ *
+ * @param p pipe to close end of
+ * @param end which end of the pipe to close
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
+int
+GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, 
+                           enum GNUNET_DISK_PipeEnd end);
 
 /**
  * Close an open file.
@@ -347,6 +364,7 @@ int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
 
 /**
  * Get the handle to a particular pipe end
+ *
  * @param p pipe
  * @param n end to access
  * @return handle for the respective end
@@ -444,7 +462,8 @@ struct GNUNET_DISK_DirectoryIterator;
  *
  * @param cls closure
  * @param di argument to pass to "GNUNET_DISK_directory_iterator_next" to
- *           get called on the next entry (or finish cleanly)
+ *           get called on the next entry (or finish cleanly);
+ *           NULL on error (will be the last call in that case)
  * @param filename complete filename (absolute path)
  * @param dirname directory name (absolute path)
  */
@@ -477,15 +496,12 @@ int GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
  * If a scheduler does not need to be used, GNUNET_DISK_directory_scan
  * may provide a simpler API.
  *
- * @param sched scheduler to use
  * @param prio priority to use
  * @param dirName the name of the directory
  * @param callback the method to call for each file
  * @param callback_cls closure for callback
  */
-void GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle
-                                           *sched,
-                                           enum GNUNET_SCHEDULER_Priority
+void GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority
                                            prio, const char *dirName,
                                            GNUNET_DISK_DirectoryIteratorCallback
                                            callback, void *callback_cls);
@@ -626,6 +642,34 @@ int GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h);
  */
 int 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 */
 {
 #endif