Home | History | Annotate | Download | only in decoder
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef __FWDLOCKFILE_H__
     18 #define __FWDLOCKFILE_H__
     19 
     20 #ifdef __cplusplus
     21 extern "C" {
     22 #endif
     23 
     24 #include <sys/types.h>
     25 
     26 /**
     27  * Attaches to an open Forward Lock file. The file position is assumed to be at the beginning of the
     28  * file.
     29  *
     30  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     31  *
     32  * @return A status code.
     33  * @retval 0 Success.
     34  * @retval -1 Failure.
     35  */
     36 int FwdLockFile_attach(int fileDesc);
     37 
     38 /**
     39  * Reads the specified number of bytes from an open Forward Lock file.
     40  *
     41  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     42  * @param[out] pBuffer A reference to the buffer that should receive the read data.
     43  * @param[in] numBytes The number of bytes to read.
     44  *
     45  * @return The number of bytes read.
     46  * @retval -1 Failure.
     47  */
     48 ssize_t FwdLockFile_read(int fileDesc, void *pBuffer, size_t numBytes);
     49 
     50 /**
     51  * Updates the file position within an open Forward Lock file.
     52  *
     53  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     54  * @param[in] offset The offset with which to update the file position.
     55  * @param[in] whence One of SEEK_SET, SEEK_CUR, and SEEK_END.
     56  *
     57  * @return The new file position.
     58  * @retval ((off64_t)-1) Failure.
     59  */
     60 off64_t FwdLockFile_lseek(int fileDesc, off64_t offset, int whence);
     61 
     62 /**
     63  * Detaches from an open Forward Lock file.
     64  *
     65  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     66  *
     67  * @return A status code.
     68  * @retval 0 Success.
     69  * @retval -1 Failure.
     70  */
     71 int FwdLockFile_detach(int fileDesc);
     72 
     73 /**
     74  * Closes an open Forward Lock file.
     75  *
     76  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     77  *
     78  * @return A status code.
     79  * @retval 0 Success.
     80  * @retval -1 Failure.
     81  */
     82 int FwdLockFile_close(int fileDesc);
     83 
     84 /**
     85  * Checks the data integrity of an open Forward Lock file.
     86  *
     87  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     88  *
     89  * @return A Boolean value indicating whether the integrity check was successful.
     90  */
     91 int FwdLockFile_CheckDataIntegrity(int fileDesc);
     92 
     93 /**
     94  * Checks the header integrity of an open Forward Lock file.
     95  *
     96  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
     97  *
     98  * @return A Boolean value indicating whether the integrity check was successful.
     99  */
    100 int FwdLockFile_CheckHeaderIntegrity(int fileDesc);
    101 
    102 /**
    103  * Checks both the data and header integrity of an open Forward Lock file.
    104  *
    105  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
    106  *
    107  * @return A Boolean value indicating whether the integrity check was successful.
    108  */
    109 int FwdLockFile_CheckIntegrity(int fileDesc);
    110 
    111 /**
    112  * Returns the content type of an open Forward Lock file.
    113  *
    114  * @param[in] fileDesc The file descriptor of an open Forward Lock file.
    115  *
    116  * @return
    117  *   A reference to the content type. The reference remains valid as long as the file is kept open.
    118  */
    119 const char *FwdLockFile_GetContentType(int fileDesc);
    120 
    121 #ifdef __cplusplus
    122 }
    123 #endif
    124 
    125 #endif // __FWDLOCKFILE_H__
    126