{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1711626043,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"3b3f72165ffff8de75a737268425ca88",
"oid":{ "oid": "e4be3317ee421f951fb16a85c7edacc9b8a0e6aa", "alias": [ "refs/heads/main"]},"blobname": "include/libwebsockets/lws-vfs.h", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \u003candy@warmcat.com\u003e\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \u0022Software\u0022), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \u0022AS IS\u0022, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/*! \u005cdefgroup fops file operation wrapping\n *\n * ##File operation wrapping\n *\n * Use these helper functions if you want to access a file from the perspective\n * of a specific wsi, which is usually the case. If you just want contextless\n * file access, use the fops callbacks directly with NULL wsi instead of these\n * helpers.\n *\n * If so, then it calls the platform handler or user overrides where present\n * (as defined in info-\u003efops)\n *\n * The advantage from all this is user code can be portable for file operations\n * without having to deal with differences between platforms.\n */\n//@{\n\n/** struct lws_plat_file_ops - Platform-specific file operations\n *\n * These provide platform-agnostic ways to deal with filesystem access in the\n * library and in the user code.\n */\n\n#if defined(LWS_PLAT_FREERTOS)\n/* sdk preprocessor defs? compiler issue? gets confused with member names */\n#define LWS_FOP_OPEN\t\t_open\n#define LWS_FOP_CLOSE\t\t_close\n#define LWS_FOP_SEEK_CUR\t_seek_cur\n#define LWS_FOP_READ\t\t_read\n#define LWS_FOP_WRITE\t\t_write\n#else\n#define LWS_FOP_OPEN\t\topen\n#define LWS_FOP_CLOSE\t\tclose\n#define LWS_FOP_SEEK_CUR\tseek_cur\n#define LWS_FOP_READ\t\tread\n#define LWS_FOP_WRITE\t\twrite\n#endif\n\n#define LWS_FOP_FLAGS_MASK\t\t ((1 \u003c\u003c 23) - 1)\n#define LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP (1 \u003c\u003c 24)\n#define LWS_FOP_FLAG_COMPR_IS_GZIP\t (1 \u003c\u003c 25)\n#define LWS_FOP_FLAG_MOD_TIME_VALID\t (1 \u003c\u003c 26)\n#define LWS_FOP_FLAG_VIRTUAL\t\t (1 \u003c\u003c 27)\n\nstruct lws_plat_file_ops;\n\nstruct lws_fop_fd {\n\tlws_filefd_type\t\t\tfd;\n\t/**\u003c real file descriptor related to the file... */\n\tconst struct lws_plat_file_ops\t*fops;\n\t/**\u003c fops that apply to this fop_fd */\n\tvoid\t\t\t\t*filesystem_priv;\n\t/**\u003c ignored by lws; owned by the fops handlers */\n\tlws_filepos_t\t\t\tpos;\n\t/**\u003c generic \u0022position in file\u0022 */\n\tlws_filepos_t\t\t\tlen;\n\t/**\u003c generic \u0022length of file\u0022 */\n\tlws_fop_flags_t\t\t\tflags;\n\t/**\u003c copy of the returned flags */\n\tuint32_t\t\t\tmod_time;\n\t/**\u003c optional \u0022modification time of file\u0022, only valid if .open()\n\t * set the LWS_FOP_FLAG_MOD_TIME_VALID flag */\n};\ntypedef struct lws_fop_fd *lws_fop_fd_t;\n\nstruct lws_fops_index {\n\tconst char *sig;\t/* NULL or vfs signature, eg, \u0022.zip/\u0022 */\n\tuint8_t len;\t\t/* length of above string */\n};\n\nstruct lws_plat_file_ops {\n\tlws_fop_fd_t (*LWS_FOP_OPEN)(const struct lws_plat_file_ops *fops_own,\n\t\t\t\t const struct lws_plat_file_ops *fops,\n\t\t\t\t const char *filename, const char *vpath,\n\t\t\t\t lws_fop_flags_t *flags);\n\t/**\u003c Open file (always binary access if plat supports it)\n\t * fops_own is the fops this was called through. fops is the base\n\t * fops the open can use to find files to process as present as its own,\n\t * like the zip fops does.\n\t *\n\t * vpath may be NULL, or if the fops understands it, the point at which\n\t * the filename's virtual part starts.\n\t * *flags \u0026 LWS_FOP_FLAGS_MASK should be set to O_RDONLY or O_RDWR.\n\t * If the file may be gzip-compressed,\n\t * LWS_FOP_FLAG_COMPR_ACCEPTABLE_GZIP is set. If it actually is\n\t * gzip-compressed, then the open handler should OR\n\t * LWS_FOP_FLAG_COMPR_IS_GZIP on to *flags before returning.\n\t */\n\tint (*LWS_FOP_CLOSE)(lws_fop_fd_t *fop_fd);\n\t/**\u003c close file AND set the pointer to NULL */\n\tlws_fileofs_t (*LWS_FOP_SEEK_CUR)(lws_fop_fd_t fop_fd,\n\t\t\t\t\t lws_fileofs_t offset_from_cur_pos);\n\t/**\u003c seek from current position */\n\tint (*LWS_FOP_READ)(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t\t uint8_t *buf, lws_filepos_t len);\n\t/**\u003c Read from file, on exit *amount is set to amount actually read */\n\tint (*LWS_FOP_WRITE)(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t\t uint8_t *buf, lws_filepos_t len);\n\t/**\u003c Write to file, on exit *amount is set to amount actually written */\n\n\tstruct lws_fops_index fi[3];\n\t/**\u003c vfs path signatures implying use of this fops */\n\n\tconst struct lws_plat_file_ops *next;\n\t/**\u003c NULL or next fops in list... eg copy static fops def to heap\n\t * and modify copy at runtime */\n\n\tstruct lws_context\t\t*cx;\n\t/**\u003c the lws_context... eg copy static fops def to heap\n\t * and modify copy at runtime */\n\n\t/* Add new things just above here ---^\n\t * This is part of the ABI, don't needlessly break compatibility */\n};\n\n/**\n * lws_get_fops() - get current file ops\n *\n * \u005cparam context: context\n */\nLWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops * LWS_WARN_UNUSED_RESULT\nlws_get_fops(struct lws_context *context);\nLWS_VISIBLE LWS_EXTERN void\nlws_set_fops(struct lws_context *context, const struct lws_plat_file_ops *fops);\n/**\n * lws_vfs_tell() - get current file position\n *\n * \u005cparam fop_fd: fop_fd we are asking about\n */\nLWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT\nlws_vfs_tell(lws_fop_fd_t fop_fd);\n/**\n * lws_vfs_get_length() - get current file total length in bytes\n *\n * \u005cparam fop_fd: fop_fd we are asking about\n */\nLWS_VISIBLE LWS_EXTERN lws_filepos_t LWS_WARN_UNUSED_RESULT\nlws_vfs_get_length(lws_fop_fd_t fop_fd);\n/**\n * lws_vfs_get_mod_time() - get time file last modified\n *\n * \u005cparam fop_fd: fop_fd we are asking about\n */\nLWS_VISIBLE LWS_EXTERN uint32_t LWS_WARN_UNUSED_RESULT\nlws_vfs_get_mod_time(lws_fop_fd_t fop_fd);\n/**\n * lws_vfs_file_seek_set() - seek relative to start of file\n *\n * \u005cparam fop_fd: fop_fd we are seeking in\n * \u005cparam offset: offset from start of file\n */\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\nlws_vfs_file_seek_set(lws_fop_fd_t fop_fd, lws_fileofs_t offset);\n/**\n * lws_vfs_file_seek_end() - seek relative to end of file\n *\n * \u005cparam fop_fd: fop_fd we are seeking in\n * \u005cparam offset: offset from start of file\n */\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\nlws_vfs_file_seek_end(lws_fop_fd_t fop_fd, lws_fileofs_t offset);\n\nextern struct lws_plat_file_ops fops_zip;\n\n/**\n * lws_plat_file_open() - open vfs filepath\n *\n * \u005cparam fops: file ops struct that applies to this descriptor\n * \u005cparam vfs_path: filename to open\n * \u005cparam flags: pointer to open flags\n *\n * The vfs_path is scanned for known fops signatures, and the open directed\n * to any matching fops open.\n *\n * User code should use this api to perform vfs opens.\n *\n * returns semi-opaque handle\n */\nLWS_VISIBLE LWS_EXTERN lws_fop_fd_t LWS_WARN_UNUSED_RESULT\nlws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_path,\n\t\t lws_fop_flags_t *flags);\n\n/**\n * lws_plat_file_close() - close file\n *\n * \u005cparam fop_fd: file handle to close\n */\nstatic LWS_INLINE int\nlws_vfs_file_close(lws_fop_fd_t *fop_fd)\n{\n\tif (*fop_fd \u0026\u0026 (*fop_fd)-\u003efops)\n\t\treturn (*fop_fd)-\u003efops-\u003eLWS_FOP_CLOSE(fop_fd);\n\n\treturn 0;\n}\n\n/**\n * lws_plat_file_seek_cur() - close file\n *\n *\n * \u005cparam fop_fd: file handle\n * \u005cparam offset: position to seek to\n */\nstatic LWS_INLINE lws_fileofs_t\nlws_vfs_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset)\n{\n\treturn fop_fd-\u003efops-\u003eLWS_FOP_SEEK_CUR(fop_fd, offset);\n}\n/**\n * lws_plat_file_read() - read from file\n *\n * \u005cparam fop_fd: file handle\n * \u005cparam amount: how much to read (rewritten by call)\n * \u005cparam buf: buffer to write to\n * \u005cparam len: max length\n */\nstatic LWS_INLINE int LWS_WARN_UNUSED_RESULT\nlws_vfs_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len)\n{\n\treturn fop_fd-\u003efops-\u003eLWS_FOP_READ(fop_fd, amount, buf, len);\n}\n/**\n * lws_plat_file_write() - write from file\n *\n * \u005cparam fop_fd: file handle\n * \u005cparam amount: how much to write (rewritten by call)\n * \u005cparam buf: buffer to read from\n * \u005cparam len: max length\n */\nstatic LWS_INLINE int LWS_WARN_UNUSED_RESULT\nlws_vfs_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len)\n{\n\treturn fop_fd-\u003efops-\u003eLWS_FOP_WRITE(fop_fd, amount, buf, len);\n}\n\n/* these are the platform file operations implementations... they can\n * be called directly and used in fops arrays\n */\n\nLWS_VISIBLE LWS_EXTERN lws_fop_fd_t\n_lws_plat_file_open(const struct lws_plat_file_ops *fops_own,\n\t\t const struct lws_plat_file_ops *fops, const char *filename,\n\t\t const char *vpath, lws_fop_flags_t *flags);\nLWS_VISIBLE LWS_EXTERN int\n_lws_plat_file_close(lws_fop_fd_t *fop_fd);\nLWS_VISIBLE LWS_EXTERN lws_fileofs_t\n_lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset);\nLWS_VISIBLE LWS_EXTERN int\n_lws_plat_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len);\nLWS_VISIBLE LWS_EXTERN int\n_lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n\t\t uint8_t *buf, lws_filepos_t len);\n\nLWS_VISIBLE LWS_EXTERN int\nlws_alloc_vfs_file(struct lws_context *context, const char *filename,\n\t\t uint8_t **buf, lws_filepos_t *amount);\n//@}\n","s":{"c":1711626043,"u": 910}}
],"g": 2808,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}