1/*
2 * Copyright (C) 2011 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 ************************************************************************
18 * @file         M4OSA_FileCommon_priv.h
19 * @ingroup      OSAL
20 * @brief        File common private for Android
21 * @note         This file declares functions and types used by both the file
22 *               writer and file reader.
23 ************************************************************************
24*/
25
26#ifndef M4OSA_FILECOMMON_PRIV_H
27#define M4OSA_FILECOMMON_PRIV_H
28
29
30#include "M4OSA_FileCommon.h"
31#include <stdio.h>
32
33#define M4OSA_isAccessModeActived(compound_mode_access,elementary_mode_access)\
34        (((compound_mode_access)&(elementary_mode_access))? 1:0)
35
36
37typedef enum M4OSA_LastSeek
38{
39   SeekNone,
40   SeekRead,
41   SeekWrite
42} M4OSA_LastSeek;
43
44/** This structure defines the file context*/
45typedef struct {
46   M4OSA_UInt32         coreID_read;
47   M4OSA_UInt32         coreID_write;
48   FILE*                file_desc;
49   /** The name of the URL */
50   M4OSA_Char*          url_name;
51   /** The name of the file */
52   M4OSA_Char*          file_name;
53   /** The size in bytes of the file */
54   M4OSA_FilePosition   file_size;
55   /** The file mode access used to open the file */
56   M4OSA_FileModeAccess access_mode;
57   M4OSA_LastSeek       current_seek;
58   M4OSA_FilePosition   read_position;
59   M4OSA_FilePosition   write_position;
60   M4OSA_Bool           b_is_end_of_file;
61
62#ifdef M4OSA_FILE_BLOCK_WITH_SEMAPHORE
63   M4OSA_Context        semaphore_context;
64#endif /* M4OSA_FILE_BLOCK_WITH_SEMAPHORE */
65
66
67   /* These two variables were added to manage case where a file
68    * is opened in read and write mode with one descriptor */
69    M4OSA_DescrModeAccess    m_DescrModeAccess;
70    M4OSA_UInt32            m_uiLockMode;
71
72
73} M4OSA_FileContext;
74
75
76
77M4OSA_ERR M4OSA_fileCommonOpen(M4OSA_UInt16 core_id,
78                               M4OSA_Context* context,
79                               M4OSA_Char* URL,
80                               M4OSA_FileModeAccess fileModeAccess);
81
82M4OSA_ERR M4OSA_fileCommonClose(M4OSA_UInt16 core_id,
83                                M4OSA_Context context);
84
85M4OSA_ERR M4OSA_fileCommonGetAttribute(M4OSA_Context context,
86                                       M4OSA_FileAttribute* attribute);
87
88M4OSA_ERR M4OSA_fileCommonGetURL(M4OSA_Context context,
89                                 M4OSA_Char** url);
90
91M4OSA_ERR M4OSA_fileCommonGetFilename(M4OSA_Char* url,
92                                      M4OSA_Char** filename);
93
94M4OSA_ERR M4OSA_fileCommonSeek(M4OSA_Context context,
95                               M4OSA_FileSeekAccessMode seekMode,
96                               M4OSA_FilePosition* position);
97
98#ifdef UTF_CONVERSION
99M4OSA_ERR M4OSA_ToUTF8_OSAL (M4OSA_Void   *pBufferIn,
100                             M4OSA_UInt8  *pBufferOut,
101                             M4OSA_UInt32 *bufferOutSize);
102#endif /*UTF_CONVERSION*/
103
104
105#endif /*M4OSA_FILECOMMON_PRIV_H*/
106
107