libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-vfs.h File Reference

Go to the source code of this file.

Data Structures

struct  lws_fop_fd
 
struct  lws_fops_index
 
struct  lws_plat_file_ops
 

Macros

#define LWS_FOP_OPEN   open
 
#define LWS_FOP_CLOSE   close
 
#define LWS_FOP_SEEK_CUR   seek_cur
 
#define LWS_FOP_READ   read
 
#define LWS_FOP_WRITE   write
 
#define LWS_FOP_FLAGS_MASK   ((1 << 23) - 1)
 
#define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP   (1 << 24)
 
#define LWS_FOP_FLAG_COMPR_IS_GZIP   (1 << 25)
 
#define LWS_FOP_FLAG_MOD_TIME_VALID   (1 << 26)
 
#define LWS_FOP_FLAG_VIRTUAL   (1 << 27)
 

Typedefs

typedef struct lws_fop_fdlws_fop_fd_t
 

Functions

LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *LWS_WARN_UNUSED_RESULT lws_get_fops (struct lws_context *context)
 
LWS_VISIBLE LWS_EXTERN void lws_set_fops (struct lws_context *context, const struct lws_plat_file_ops *fops)
 
LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT lws_vfs_tell (lws_fop_fd_t fop_fd)
 
LWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT lws_vfs_get_length (lws_fop_fd_t fop_fd)
 
LWS_VISIBLE LWS_EXTERN uint32_t LWS_WARN_UNUSED_RESULT lws_vfs_get_mod_time (lws_fop_fd_t fop_fd)
 
LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_set (lws_fop_fd_t fop_fd, lws_fileofs_t offset)
 
LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_end (lws_fop_fd_t fop_fd, lws_fileofs_t offset)
 
LWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT lws_vfs_file_open (const struct lws_plat_file_ops *fops, const char *vfs_path, lws_fop_flags_t *flags)
 
LWS_VISIBLE LWS_EXTERN lws_fop_fd_t _lws_plat_file_open (const struct lws_plat_file_ops *fops_own, const struct lws_plat_file_ops *fops, const char *filename, const char *vpath, lws_fop_flags_t *flags)
 
LWS_VISIBLE LWS_EXTERN int _lws_plat_file_close (lws_fop_fd_t *fop_fd)
 
LWS_VISIBLE LWS_EXTERN lws_fileofs_t _lws_plat_file_seek_cur (lws_fop_fd_t fop_fd, lws_fileofs_t offset)
 
LWS_VISIBLE LWS_EXTERN int _lws_plat_file_read (lws_fop_fd_t fop_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len)
 
LWS_VISIBLE LWS_EXTERN int _lws_plat_file_write (lws_fop_fd_t fop_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len)
 
LWS_VISIBLE LWS_EXTERN int lws_alloc_vfs_file (struct lws_context *context, const char *filename, uint8_t **buf, lws_filepos_t *amount)
 

Variables

struct lws_plat_file_ops fops_zip
 

Data Structure Documentation

◆ lws_fop_fd

struct lws_fop_fd

Definition at line 71 of file lws-vfs.h.

+ Collaboration diagram for lws_fop_fd:
Data Fields
lws_filefd_type fd

real file descriptor related to the file...

const struct lws_plat_file_ops * fops

fops that apply to this fop_fd

void * filesystem_priv

ignored by lws; owned by the fops handlers

lws_filepos_t pos

generic "position in file"

lws_filepos_t len

generic "length of file"

lws_fop_flags_t flags

copy of the returned flags

uint32_t mod_time

optional "modification time of file", only valid if .open() set the LWS_FOP_FLAG_MOD_TIME_VALID flag

◆ lws_fops_index

struct lws_fops_index

Definition at line 90 of file lws-vfs.h.

+ Collaboration diagram for lws_fops_index:
Data Fields
const char * sig
uint8_t len

◆ lws_plat_file_ops

struct lws_plat_file_ops

Definition at line 95 of file lws-vfs.h.

+ Collaboration diagram for lws_plat_file_ops:
Data Fields
lws_fop_fd_t(*)(const struct lws_plat_file_ops *fops_own, const struct lws_plat_file_ops *fops, const char *filename, const char *vpath, lws_fop_flags_t *flags) LWS_FOP_OPEN

Open file (always binary access if plat supports it) fops_own is the fops this was called through. fops is the base fops the open can use to find files to process as present as its own, like the zip fops does.

vpath may be NULL, or if the fops understands it, the point at which the filename's virtual part starts. *flags & LWS_FOP_FLAGS_MASK should be set to O_RDONLY or O_RDWR. If the file may be gzip-compressed, LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP is set. If it actually is gzip-compressed, then the open handler should OR LWS_FOP_FLAG_COMPR_IS_GZIP on to *flags before returning.

int(*)(lws_fop_fd_t *fop_fd) LWS_FOP_CLOSE

close file AND set the pointer to NULL

lws_fileofs_t(*)(lws_fop_fd_t fop_fd, lws_fileofs_t offset_from_cur_pos) LWS_FOP_SEEK_CUR

seek from current position

int(*)(lws_fop_fd_t fop_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len) LWS_FOP_READ

Read from file, on exit *amount is set to amount actually read

int(*)(lws_fop_fd_t fop_fd, lws_filepos_t *amount, uint8_t *buf, lws_filepos_t len) LWS_FOP_WRITE

Write to file, on exit *amount is set to amount actually written

struct lws_fops_index fi[3]

vfs path signatures implying use of this fops

const struct lws_plat_file_ops * next

NULL or next fops in list... eg copy static fops def to heap and modify copy at runtime

struct lws_context * cx

the lws_context... eg copy static fops def to heap and modify copy at runtime

Macro Definition Documentation

◆ LWS_FOP_OPEN

#define LWS_FOP_OPEN   open

struct lws_plat_file_ops - Platform-specific file operations

These provide platform-agnostic ways to deal with filesystem access in the library and in the user code.

Definition at line 56 of file lws-vfs.h.

◆ LWS_FOP_CLOSE

#define LWS_FOP_CLOSE   close

Definition at line 57 of file lws-vfs.h.

◆ LWS_FOP_SEEK_CUR

#define LWS_FOP_SEEK_CUR   seek_cur

Definition at line 58 of file lws-vfs.h.

◆ LWS_FOP_READ

#define LWS_FOP_READ   read

Definition at line 59 of file lws-vfs.h.

◆ LWS_FOP_WRITE

#define LWS_FOP_WRITE   write

Definition at line 60 of file lws-vfs.h.

◆ LWS_FOP_FLAGS_MASK

#define LWS_FOP_FLAGS_MASK   ((1 << 23) - 1)

Definition at line 63 of file lws-vfs.h.

◆ LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP

#define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP   (1 << 24)

Definition at line 64 of file lws-vfs.h.

◆ LWS_FOP_FLAG_COMPR_IS_GZIP

#define LWS_FOP_FLAG_COMPR_IS_GZIP   (1 << 25)

Definition at line 65 of file lws-vfs.h.

◆ LWS_FOP_FLAG_MOD_TIME_VALID

#define LWS_FOP_FLAG_MOD_TIME_VALID   (1 << 26)

Definition at line 66 of file lws-vfs.h.

◆ LWS_FOP_FLAG_VIRTUAL

#define LWS_FOP_FLAG_VIRTUAL   (1 << 27)

Definition at line 67 of file lws-vfs.h.

Typedef Documentation

◆ lws_fop_fd_t

typedef struct lws_fop_fd* lws_fop_fd_t

Definition at line 88 of file lws-vfs.h.

Function Documentation

◆ lws_get_fops()

LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *LWS_WARN_UNUSED_RESULT lws_get_fops ( struct lws_context * context)

lws_get_fops() - get current file ops

Parameters
contextcontext

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_set_fops()

LWS_VISIBLE LWS_EXTERN void lws_set_fops ( struct lws_context * context,
const struct lws_plat_file_ops * fops )

◆ lws_vfs_tell()

lws_vfs_tell() - get current file position

Parameters
fop_fdfop_fd we are asking about

References LWS_EXTERN, LWS_VISIBLE, and LWS_WARN_UNUSED_RESULT.

◆ lws_vfs_get_length()

lws_vfs_get_length() - get current file total length in bytes

Parameters
fop_fdfop_fd we are asking about

References LWS_EXTERN, LWS_VISIBLE, and LWS_WARN_UNUSED_RESULT.

◆ lws_vfs_get_mod_time()

lws_vfs_get_mod_time() - get time file last modified

Parameters
fop_fdfop_fd we are asking about

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_vfs_file_seek_set()

LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_set ( lws_fop_fd_t fop_fd,
lws_fileofs_t offset )

lws_vfs_file_seek_set() - seek relative to start of file

Parameters
fop_fdfop_fd we are seeking in
offsetoffset from start of file

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_vfs_file_seek_end()

LWS_VISIBLE LWS_EXTERN lws_fileofs_t lws_vfs_file_seek_end ( lws_fop_fd_t fop_fd,
lws_fileofs_t offset )

lws_vfs_file_seek_end() - seek relative to end of file

Parameters
fop_fdfop_fd we are seeking in
offsetoffset from start of file

References fops_zip, LWS_EXTERN, LWS_VISIBLE, and LWS_WARN_UNUSED_RESULT.

◆ lws_vfs_file_open()

LWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT lws_vfs_file_open ( const struct lws_plat_file_ops * fops,
const char * vfs_path,
lws_fop_flags_t * flags )

lws_plat_file_open() - open vfs filepath

Parameters
fopsfile ops struct that applies to this descriptor
vfs_pathfilename to open
flagspointer to open flags

The vfs_path is scanned for known fops signatures, and the open directed to any matching fops open.

User code should use this api to perform vfs opens.

returns semi-opaque handle

References LWS_INLINE.

◆ _lws_plat_file_open()

LWS_VISIBLE LWS_EXTERN lws_fop_fd_t _lws_plat_file_open ( const struct lws_plat_file_ops * fops_own,
const struct lws_plat_file_ops * fops,
const char * filename,
const char * vpath,
lws_fop_flags_t * flags )

References LWS_EXTERN, and LWS_VISIBLE.

◆ _lws_plat_file_close()

LWS_VISIBLE LWS_EXTERN int _lws_plat_file_close ( lws_fop_fd_t * fop_fd)

References LWS_EXTERN, and LWS_VISIBLE.

◆ _lws_plat_file_seek_cur()

LWS_VISIBLE LWS_EXTERN lws_fileofs_t _lws_plat_file_seek_cur ( lws_fop_fd_t fop_fd,
lws_fileofs_t offset )

References LWS_EXTERN, and LWS_VISIBLE.

◆ _lws_plat_file_read()

LWS_VISIBLE LWS_EXTERN int _lws_plat_file_read ( lws_fop_fd_t fop_fd,
lws_filepos_t * amount,
uint8_t * buf,
lws_filepos_t len )

References LWS_EXTERN, and LWS_VISIBLE.

◆ _lws_plat_file_write()

LWS_VISIBLE LWS_EXTERN int _lws_plat_file_write ( lws_fop_fd_t fop_fd,
lws_filepos_t * amount,
uint8_t * buf,
lws_filepos_t len )

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_alloc_vfs_file()

LWS_VISIBLE LWS_EXTERN int lws_alloc_vfs_file ( struct lws_context * context,
const char * filename,
uint8_t ** buf,
lws_filepos_t * amount )

Variable Documentation

◆ fops_zip

struct lws_plat_file_ops fops_zip
extern

Referenced by lws_vfs_file_seek_end().