* Added silc_file_set_nonblock. Affected file is
lib/silcutil/silcfileutil.h.
+ * Added silc_fd_stream_file to lib/silcutil/silcfdstream.[ch].
+
Sat Nov 26 16:13:40 EET 2005 Pekka Riikonen <priikone@silcnet.org>
* FSM based implementation of SILC SKE. Simpler interface also.
return stream;
}
+/* Create by opening file */
+
+SilcStream silc_fd_stream_file(const char *filename,
+ SilcBool reading, SilcBool writing,
+ SilcSchedule schedule)
+{
+ int fd, flags = 0;
+
+ if (!filename)
+ return NULL;
+
+ if (reading)
+ flags |= O_RDONLY;
+ if (writing)
+ flags |= O_WRONLY;
+ if (reading && writing)
+ flags |= O_RDWR;
+
+ fd = silc_file_open(filename, flags);
+ if (fd < 0)
+ return NULL;
+
+ return silc_fd_stream_create(fd, schedule);
+}
+
/* Return fds */
SilcBool silc_fd_stream_get_info(SilcStream stream, int *read_fd, int *write_fd)
SilcStream silc_fd_stream_create2(int read_fd, int write_fd,
SilcSchedule schedule);
+/****f* silcutil/SilcFDStreamAPI/silc_fd_stream_file
+ *
+ * SYNOPSIS
+ *
+ * SilcStream silc_fd_stream_file(const char *filename, SilcBool reading,
+ * SilcBool writing, SilcSchedule schedule);
+ *
+ * DESCRIPTION
+ *
+ * Same as silc_fd_stream_create but creates the stream by opening the
+ * file indicated by `filename'. If the `reading' is TRUE the file is
+ * opened for reading. If the `writing' is TRUE the file is opened
+ * for writing.
+ *
+ ***/
+SilcStream silc_fd_stream_file(const char *filename, SilcBool reading,
+ SilcBool writing, SilcSchedule schedule);
+
/****f* silcutil/SilcFDStreamAPI/silc_fd_stream_get_info
*
* SYNOPSIS
***/
int silc_file_close(int fd);
-/****f* silcutil/SilcNetAPI/silc_file_set_nonblock
+/****f* silcutil/SilcFileUtilAPI/silc_file_set_nonblock
*
* SYNOPSIS
*
***/
typedef struct SilcMutexStruct *SilcMutex;
-/****d* silcutil/SilcMutexAPI/SILC_MUTEX_DEFINE
- *
- * NAME
- *
- * #define SILC_MUTEX_DEFINE(name) ...
- *
- * DESCRIPTION
- *
- * This macro is used to define new mutex. Use this macro in an
- * environment that can be compiled with or without the SILC Mutex
- * API. This is equivalent to defining SilcMutex `name'; directly.
- *
- * SOURCE
- */
-#define SILC_MUTEX_DEFINE(name) SilcMutex name
-/***/
-
/****f* silcutil/SilcMutexAPI/silc_mutex_alloc
*
* SYNOPSIS