projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added SILC Thread Queue API
[silc.git]
/
lib
/
silcutil
/
silcfileutil.h
diff --git
a/lib/silcutil/silcfileutil.h
b/lib/silcutil/silcfileutil.h
index f388e25a876c17cb1bf900b9c5ab05fbfc8da757..b3b0312c31b14cac69ea23e78f411bf9657dfc7c 100644
(file)
--- a/
lib/silcutil/silcfileutil.h
+++ b/
lib/silcutil/silcfileutil.h
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 200
2
Pekka Riikonen
+ Copyright (C) 1997 - 200
7
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-40,7
+40,9
@@
* DESCRIPTION
*
* Opens a file indicated by the filename `filename' with flags indicated
* DESCRIPTION
*
* Opens a file indicated by the filename `filename' with flags indicated
- * by `flags'. The opening permission defaults to 0600.
+ * by `flags'. The opening permission defaults to 0600. The `flags'
+ * are defined in open(2). Returns the opened file descriptor or -1 on
+ * error.
*
***/
int silc_file_open(const char *filename, int flags);
*
***/
int silc_file_open(const char *filename, int flags);
@@
-55,7
+57,8
@@
int silc_file_open(const char *filename, int flags);
*
* Opens a file indicated by the filename `filename' with flags indicated
* by `flags'. The argument `mode' specifies the permissions to use in
*
* Opens a file indicated by the filename `filename' with flags indicated
* by `flags'. The argument `mode' specifies the permissions to use in
- * case a new file is created.
+ * case a new file is created. The `flags' are defined in open(2).
+ * Returns the opened file descriptor or -1 on error and sets silc_errno.
*
***/
int silc_file_open_mode(const char *filename, int flags, int mode);
*
***/
int silc_file_open_mode(const char *filename, int flags, int mode);
@@
-68,7
+71,8
@@
int silc_file_open_mode(const char *filename, int flags, int mode);
*
* DESCRIPTION
*
*
* DESCRIPTION
*
- * Reads data from file descriptor `fd' to `buf'.
+ * Reads data from file descriptor `fd' to `buf'. Returns the amount of
+ * bytes read, 0 on EOF or -1 on error and sets silc_errno.
*
***/
int silc_file_read(int fd, unsigned char *buf, SilcUInt32 buf_len);
*
***/
int silc_file_read(int fd, unsigned char *buf, SilcUInt32 buf_len);
@@
-81,7
+85,8
@@
int silc_file_read(int fd, unsigned char *buf, SilcUInt32 buf_len);
*
* DESCRIPTION
*
*
* DESCRIPTION
*
- * Writes `buffer' of length of `len' to file descriptor `fd'.
+ * Writes `buffer' of length of `len' to file descriptor `fd'. Returns
+ * the amount of bytes written, 0 on EOF or -1 on error and sets silc_errno.
*
***/
int silc_file_write(int fd, const char *buffer, SilcUInt32 len);
*
***/
int silc_file_write(int fd, const char *buffer, SilcUInt32 len);
@@
-95,25
+100,48
@@
int silc_file_write(int fd, const char *buffer, SilcUInt32 len);
* DESCRIPTION
*
* Closes file descriptor previously opened with silc_file_open().
* DESCRIPTION
*
* Closes file descriptor previously opened with silc_file_open().
+ * Returns 0 on success or -1 on error and sets silc_errno.
*
***/
int silc_file_close(int fd);
*
***/
int silc_file_close(int fd);
+/****f* silcutil/SilcFileUtilAPI/silc_file_set_nonblock
+ *
+ * SYNOPSIS
+ *
+ * int silc_file_set_nonblock(int fd);
+ *
+ * DESCRIPTION
+ *
+ * Sets the file descriptor to non-blocking mode.
+ *
+ ***/
+int silc_file_set_nonblock(int fd);
+
/****f* silcutil/SilcFileUtilAPI/silc_file_readfile
*
* SYNOPSIS
*
/****f* silcutil/SilcFileUtilAPI/silc_file_readfile
*
* SYNOPSIS
*
- * char *silc_file_readfile(const char *filename, SilcUInt32 *return_len);
+ * char *silc_file_readfile(const char *filename, SilcUInt32 *return_len,
+ * SilcStack stack);
*
* DESCRIPTION
*
* Reads the content of `filename' to a buffer. The allocated buffer is
*
* DESCRIPTION
*
* Reads the content of `filename' to a buffer. The allocated buffer is
- * returned.
+ * returned. This does not NULL terminate the buffer but EOF terminate
+ * it. The caller must replace the EOF with NULL if the buffer must be
+ * NULL terminated.
+ *
* If the `return_len' pointer is not NULL, it's filled with the length of
* the file.
*
* If the `return_len' pointer is not NULL, it's filled with the length of
* the file.
*
+ * If `stack' is non-NULL the returned buffer is allocated from `stack'.
+ * The allocation consumes `stack' so caller should push the stack before
+ * calling this function and pop it later.
+ *
***/
***/
-char *silc_file_readfile(const char *filename, SilcUInt32 *return_len);
+char *silc_file_readfile(const char *filename, SilcUInt32 *return_len,
+ SilcStack stack);
/****f* silcutil/SilcFileUtilAPI/silc_file_writefile
*
/****f* silcutil/SilcFileUtilAPI/silc_file_writefile
*