chenqiyang
2022-09-02 6a99d9bf65aa5878cb409945ed2bdbdcb916d047
Shared.IOS.HDLLinphoneSDK/Shared.IOS.HDLLinphoneSDK/Library/bctoolbox.framework/Headers/vfs.h
@@ -1,21 +1,21 @@
/*
vfs.h
Copyright (C) 2016 Belledonne Communications SARL
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 the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
 * Copyright (c) 2016-2020 Belledonne Communications SARL.
 *
 * This file is part of bctoolbox.
 *
 * 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
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef BCTBX_VFS_H
#define BCTBX_VFS_H
@@ -54,6 +54,8 @@
#define BCTBX_VFS_ERROR       -255   /* Some kind of disk I/O error occurred */
#define BCTBX_VFS_PRINTF_PAGE_SIZE 4096 /* Size of the page hold in memory by fprintf */
#define BCTBX_VFS_GETLINE_PAGE_SIZE 17385 /* Size of the page hold in memory by getnextline */
#ifdef __cplusplus
extern "C"{
@@ -73,9 +75,16 @@
   const struct bctbx_io_methods_t *pMethods;  /* Methods for an open file: all Developpers must supply this field at open step*/
   /*the fields below are used by the default implementation. Developpers are not required to supply them, but may use them if they find
    * them useful*/
   void* pUserData;             /*Developpers can store private data under this pointer */
   int fd;                         /* File descriptor */
   off_t offset;               /*File offset used by lseek*/
   void* pUserData;             /* Developpers can store private data under this pointer */
   off_t offset;               /* File offset used by bctbx_file_fprintf and bctbx_file_get_nxtline */
   /* fprintf cache */
   char fPage[BCTBX_VFS_PRINTF_PAGE_SIZE];      /* Buffer storing the current page cached by fprintf */
   off_t fPageOffset;            /* The original offset of the cached page */
   size_t fSize;               /* number of bytes in cache */
   /* get_nxtline cache */
   char gPage[BCTBX_VFS_GETLINE_PAGE_SIZE+1];   /* Buffer storing the current page cachec by get_nxtline +1 to hold the \0 */
   off_t gPageOffset;            /* The offset of the cached page */
   size_t gSize;               /* actual size of the data in cache */
};
@@ -87,8 +96,9 @@
   ssize_t (*pFuncWrite)(bctbx_vfs_file_t *pFile, const void* buf, size_t count, off_t offset);
   int (*pFuncTruncate)(bctbx_vfs_file_t *pFile, int64_t size);
   int64_t (*pFuncFileSize)(bctbx_vfs_file_t *pFile);
   int (*pFuncSync)(bctbx_vfs_file_t *pFile);
   int (*pFuncGetLineFromFd)(bctbx_vfs_file_t *pFile, char* s, int count);
   off_t (*pFuncSeek)(bctbx_vfs_file_t *pFile, off_t offset, int whence);
   bool_t (*pFuncIsEncrypted)(bctbx_vfs_file_t *pFile);
};
@@ -100,14 +110,6 @@
   const char *vfsName;       /* Virtual file system name */
   int (*pFuncOpen)(bctbx_vfs_t *pVfs, bctbx_vfs_file_t *pFile, const char *fName, int openFlags);
};
/* API to use the VFS */
/*
 * This function returns a pointer to the VFS implemented in this file.
 */
BCTBX_PUBLIC bctbx_vfs_t *bc_create_vfs(void);
/**
 * Attempts to read count bytes from the open file given by pFile, at the position starting at offset
@@ -196,7 +198,16 @@
BCTBX_PUBLIC int bctbx_file_get_nxtline(bctbx_vfs_file_t *pFile, char *s, int maxlen);
/**
 * Wrapper to pFuncSeek VFS method call. Set the position to offset in the file.
 * Simply sync the file contents given through the file handle
 * to the persistent media.
 * @param  pFile  File handle pointer.
 * @return   BCTBX_VFS_OK on success, BCTBX_VFS_ERROR otherwise
 */
BCTBX_PUBLIC int bctbx_file_sync(bctbx_vfs_file_t *pFile);
/**
 * Set the position to offset in the file, this position is used only by the function
 * bctbx_file_get_nxtline. Read and write give their own offset as param and won't modify this one
 * @param  pFile  File handle pointer.
 * @param  offset File offset where to set the position to.
 * @param  whence Either SEEK_SET, SEEK_CUR,SEEK_END
@@ -204,6 +215,12 @@
 */
BCTBX_PUBLIC off_t bctbx_file_seek(bctbx_vfs_file_t *pFile, off_t offset, int whence);
/**
 * Get the file encryption status
 * @param  pFile  File handle pointer.
 * @return true if the file is encrypted
 */
BCTBX_PUBLIC bool_t bctbx_file_is_encrypted(bctbx_vfs_file_t *pFile);
/**
 * Set default VFS pointer pDefault to my_vfs.