The test server shows how to use it, basically the platform-specific part of
lws prepares a file operations structure that lives in the lws context.
-The user code can get a pointer to the file operations struct
-
-LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *
-lws_get_fops(struct lws_context *context);
-
-and then can use it with helpers to also leverage these platform-independent
-file handling apis
+Helpers are provided to also leverage these platform-independent file handling
+apis
static inline lws_filefd_type
-lws_plat_file_open(struct lws_plat_file_ops *fops, const char *filename,
+lws_plat_file_open(struct lws *wsi, const char *filename,
unsigned long *filelen, int flags)
-
static inline int
-lws_plat_file_close(struct lws_plat_file_ops *fops, lws_filefd_type fd)
+lws_plat_file_close(struct lws *wsi, lws_filefd_type fd)
static inline unsigned long
-lws_plat_file_seek_cur(struct lws_plat_file_ops *fops, lws_filefd_type fd,
- long offset_from_cur_pos)
+lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset)
static inline int
-lws_plat_file_read(struct lws_plat_file_ops *fops, lws_filefd_type fd,
- unsigned long *amount, unsigned char *buf, unsigned long len)
+lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
+ unsigned char *buf, unsigned long len)
static inline int
-lws_plat_file_write(struct lws_plat_file_ops *fops, lws_filefd_type fd,
- unsigned long *amount, unsigned char *buf, unsigned long len)
+lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
+ unsigned char *buf, unsigned long len)
The user code can also override or subclass the file operations, to either
wrap or replace them. An example is shown in test server.
+A wsi can be associated with the file activity, allowing per-connection
+authentication and state to be used when interpreting the file request.
+
2) A new API void * lws_wsi_user(struct lws *wsi) lets you get the pointer to
the user data associated with the wsi, just from the wsi.