blob: c5d054e7704301d46aaf37b0d6f645b3fc213638 [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
2 *
3 * Copyright (C) 2000-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18#ifndef GOEP_FS_H
19#define GOEP_FS_H
20
21#include "bt_target.h"
22
23/*****************************************************************************
24** Constants
25*****************************************************************************/
26
27/* Flags passed to the open function (tGOEP_OPEN_CBACK)
28** Values are OR'd together. (First 3 are
29** mutually exclusive.
30*/
31#define GOEP_O_RDONLY 0x0000
32#define GOEP_O_WRONLY 0x0001
33#define GOEP_O_RDWR 0x0002
34
35#define GOEP_O_CREAT 0x0100
36#define GOEP_O_EXCL 0x0200
37#define GOEP_O_TRUNC 0x1000
38
39
40#define GOEP_LEN_UNKNOWN 0xFFFFFFFF
41#define GOEP_INVALID_FD (-1)
42
43/* Values passed to the access function (tGOEP_ACCESS_CBACK)
44*/
45#define GOEP_ACC_EXIST 0x0
46#define GOEP_ACC_READ 0x4
47#define GOEP_ACC_RDWR 0x6
48
49/* Constants used in directory listing structure */
50#define GOEP_A_RDONLY 0x1
51#define GOEP_A_DIR 0x2 /* Entry is a sub directory */
52
53#define GOEP_CTIME_LEN 17 /* Creation time "yyyymmddTHHMMSSZ" */
54
55/*****************************************************************************
56** Seek Constants
57*****************************************************************************/
58/* Origin for the seek function (tGOEP_SEEK_CBACK) */
59#define GOEP_SEEK_SET 0
60#define GOEP_SEEK_CUR 1
61#define GOEP_SEEK_END 2
62
63
64
65/*****************************************************************************
66** Typedefs
67*****************************************************************************/
68typedef INT32 tGOEP_FD;
69
70enum
71{
72 GOEP_OK,
73 GOEP_FAIL,
74 GOEP_EACCES,
75 GOEP_ENOTEMPTY,
76 GOEP_EOF,
77 GOEP_EODIR,
78 GOEP_ENOSPACE,
79 GOEP_EIS_DIR,
80 GOEP_RESUME,
81 GOEP_NONE
82};
83typedef UINT16 tGOEP_STATUS;
84
85/* Structure passed in Directory Entry Callback to be filled in */
86typedef struct
87{
88 UINT32 refdata; /* holder for OS specific data used to get next entry */
89 UINT32 filesize;
90 char crtime[GOEP_CTIME_LEN]; /* "yyyymmddTHHMMSSZ", or "" if none */
91 char *p_name; /* Contains the addr of memory to copy name into */
92 UINT8 mode; /* GOEP_A_RDONLY and/or GOEP_A_DIR */
93} tGOEP_DIRENTRY;
94
95
96/*****************************************************************************
97** Typedefs for messages from response functions
98*****************************************************************************/
99typedef struct
100{
101 BT_HDR hdr;
102 tGOEP_FD fd;
103 tGOEP_STATUS status;
104 UINT32 file_size;
105} tGOEP_OPEN_RSP;
106
107typedef struct
108{
109 BT_HDR hdr;
110 tGOEP_FD fd;
111 tGOEP_STATUS status;
112 UINT16 bytes_read;
113} tGOEP_READ_RSP;
114
115typedef struct
116{
117 BT_HDR hdr;
118 tGOEP_FD fd;
119 tGOEP_STATUS status;
120} tGOEP_WRITE_RSP;
121
122typedef struct
123{
124 BT_HDR hdr;
125 tGOEP_STATUS status;
126} tGOEP_DIRENTRY_RSP;
127
128/*****************************************************************************
129** Object Store Interface
130*****************************************************************************/
131/*******************************************************************************
132**
133** Callback Function: tGOEP_OPEN_CBACK
134**
135** Description This function is executed by OBX profiles to open
136** a file for reading or writing.
137**
138** Parameters p_path - Fully qualified path and file name.
139** flags - permissions and mode (see constants above)
140** size - size of file to put (0 if unavailable or not applicable)
141** event_id - code that must be passed to the call-in function.
142**
143** Returns void
144**
145** Note: Upon completion of the request, a file descriptor (tGOEP_FD),
146** file size (UINT32), and an status code (tGOEP_STATUS)
147** are returned in GOEP_OpenRsp().
148**
149*******************************************************************************/
150typedef void (tGOEP_OPEN_CBACK) (const UINT8 *p_name, UINT16 flags, UINT32 size,
151 UINT16 event_id, UINT8 app_id);
152
153/*******************************************************************************
154**
155** Callback Function: tGOEP_CLOSE_CBACK
156**
157** Description This function is executed by OBX profiles when the file descriptor
158** is no longer in use.
159**
160** Returns void
161**
162*******************************************************************************/
163typedef void (tGOEP_CLOSE_CBACK) (tGOEP_FD fd, UINT8 app_id);
164
165/*******************************************************************************
166**
167** Callback Function: tGOEP_READ_CBACK
168**
169** Description This function is executed by OBX profiles to read in data from the
170** previously opened file.
171**
172** Returns void
173**
174** Note: Upon completion of the request, GOEP_ReadRsp() is
175** called with the buffer of data, along with the number
176** of bytes read into the buffer, and a status. The
177** call-in function should only be called when ALL requested
178** bytes have been read, the end of file has been detected,
179** or an error has occurred.
180**
181*******************************************************************************/
182typedef void (tGOEP_READ_CBACK) (tGOEP_FD fd, void *p_data, INT16 size,
183 UINT16 event_id, UINT8 app_id);
184
185/*******************************************************************************
186**
187** Callback Function: tGOEP_WRITE_CBACK
188**
189** Description This function is executed by OBX profiles to write the data to the
190** previously opened file.
191**
192** Returns void
193**
194** Note: Upon completion of the request, GOEP_WriteRsp() is
195** called with the file descriptor and the status. The
196** call-in function should only be called when ALL requested
197** bytes have been written, or an error has been detected,
198**
199*******************************************************************************/
200typedef void (tGOEP_WRITE_CBACK) (tGOEP_FD fd, const void *p_data, INT16 size,
201 UINT16 event_id, UINT8 app_id);
202
203/*******************************************************************************
204**
205** Callback Function: tGOEP_SEEK_CBACK
206**
207** Description This function is executed by OBX profiles to Move a file pointer
208** of a previously opened file to the specified location for the
209** next read or write operation.
210**
211** Returns void
212**
213*******************************************************************************/
214typedef void (tGOEP_SEEK_CBACK) (tGOEP_FD fd, INT32 offset, INT16 origin, UINT8 app_id);
215
216
217/*******************************************************************************
218**
219** Callback Function: tGOEP_DIRENTRY_CBACK
220**
221** Description This function is called to retrieve a directory entry for the
222** specified path. The first/next directory should be filled
223** into the location specified by p_entry.
224**
225** Parameters p_path - directory to search (Fully qualified path)
226** first_item - TRUE if first search, FALSE if next search
227** (p_cur contains previous)
228** p_entry (input/output) - Points to last entry data (valid when
229** first_item is FALSE)
230** event_id - event that must be passed into the call-in function.
231**
232** Returns void
233**
234** Note: Upon completion of the request, GOEP_DirentryRsp() is
235** filled in entry and the status.
236** GOEP_OK is returned when p_entry is valid,
237** GOEP_EODIR is returned when no more entries [finished]
238** GOEP_FAIL is returned if an error occurred
239**
240*******************************************************************************/
241typedef void (tGOEP_DIRENTRY_CBACK) (const char *p_path, BOOLEAN first_item,
242 tGOEP_DIRENTRY *p_entry, UINT16 event_id,
243 UINT8 app_id);
244
245/*******************************************************************************
246**
247** Callback Function: tGOEP_ACCESS_CBACK
248**
249** Description This function is called to check the existence of a file or
250** directory.
251**
252** Returns (tGOEP_STATUS) status of the call.
253** [GOEP_OK if it exists]
254** [GOEP_EACCES if permissions are wrong]
255** [GOEP_FAIL if it does not exist]
256**
257*******************************************************************************/
258typedef tGOEP_STATUS (tGOEP_ACCESS_CBACK) (const char *p_path, UINT16 mode,
259 BOOLEAN *p_is_dir, UINT8 app_id);
260
261/*******************************************************************************
262**
263** Callback Function: tGOEP_MKDIR_CBACK
264**
265** Description This function is called to create a directory with
266** the pathname given by path. The pathname is a null terminated
267** string. All components of the path must already exist.
268**
269** Parameters p_path - (input) name of directory to create (fully qualified path).
270**
271** Returns (tGOEP_STATUS) status of the call.
272** [GOEP_OK if successful]
273** [GOEP_FAIL if unsuccessful]
274**
275*******************************************************************************/
276typedef tGOEP_STATUS (tGOEP_MKDIR_CBACK) (const char *p_path, UINT8 app_id);
277
278/*******************************************************************************
279**
280** Callback Function: tGOEP_RMDIR_CBACK
281**
282** Description This function is called to remove a directory whose
283** name is given by path. The directory must be empty.
284**
285** Parameters p_path - (input) name of directory to remove (fully qualified path).
286**
287** Returns (tGOEP_STATUS) status of the call.
288** [GOEP_OK if successful]
289** [GOEP_EACCES if read-only]
290** [GOEP_ENOTEMPTY if directory is not empty]
291** [GOEP_FAIL otherwise]
292**
293*******************************************************************************/
294typedef tGOEP_STATUS (tGOEP_RMDIR_CBACK) (const char *p_path, UINT8 app_id);
295
296/*******************************************************************************
297**
298** Callback Function: tGOEP_UNLINK_CBACK
299**
300** Description This function is called to remove a directory whose
301** name is given by path. The directory must be empty.
302**
303** Parameters p_path - (input) name of file to remove (fully qualified path).
304**
305** Returns (tGOEP_STATUS) status of the call.
306** [GOEP_OK if successful]
307** [GOEP_EACCES if read-only]
308** [GOEP_FAIL otherwise]
309**
310*******************************************************************************/
311typedef tGOEP_STATUS (tGOEP_UNLINK_CBACK) (const char *p_path, UINT8 app_id);
312
313
314/*****************************************************************************
315** Prototypes
316*****************************************************************************/
317
318#ifdef __cplusplus
319extern "C" {
320#endif
321
322/*****************************************************************************
323**
324** Function: GOEP_OpenRsp
325**
326** Purpose: Report the status of tGOEP_OPEN_CBACK callback function.
327**
328** Parameters: fd - File handle.
329** status - Status of the operation.
330** file_size - total number of bytes in this file.
331** event_id - event id as given in the tGOEP_OPEN_CBACK function.
332**
333** Returns: void
334**
335*****************************************************************************/
336GOEP_API extern void GOEP_OpenRsp (tGOEP_FD fd, tGOEP_STATUS status,
337 UINT32 file_size, UINT16 event_id);
338
339/*****************************************************************************
340**
341** Function: GOEP_ReadRsp
342**
343** Purpose: Report the status of tGOEP_READ_CBACK callback function.
344**
345** Parameters: fd - File handle.
346** status - Status of the operation.
347** bytes_read - total number of bytes read from the file.
348** event_id - event id as given in the tGOEP_READ_CBACK function.
349**
350** Returns: void
351**
352*****************************************************************************/
353GOEP_API extern void GOEP_ReadRsp (tGOEP_FD fd, tGOEP_STATUS status,
354 UINT16 bytes_read, UINT16 event_id);
355
356/*****************************************************************************
357**
358** Function: GOEP_WriteRsp
359**
360** Purpose: Report the status of tGOEP_WRITE_CBACK callback function.
361**
362** Parameters: fd - File handle.
363** status - Status of the operation.
364** event_id - event id as given in the tGOEP_WRITE_CBACK function.
365**
366** Returns: void
367**
368*****************************************************************************/
369GOEP_API extern void GOEP_WriteRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 event_id);
370
371/*******************************************************************************
372**
373** Function GOEP_DirentryRsp
374**
375** Description This function is called in response to the
376** tGOEP_DIRENTRY_CBACK function with a filled in directory listing
377** entry.
378**
379** Parameters status - GOEP_OK if p_entry points to a valid entry.
380** GOEP_EODIR if no more entries (p_entry is ignored).
381** GOEP_FAIL if any errors have occurred.
382** event_id - event id as given in the tGOEP_DIRENTRY_CBACK function.
383**
384** Returns void
385**
386*******************************************************************************/
387GOEP_API extern void GOEP_DirentryRsp(tGOEP_STATUS status, UINT16 event_id);
388
389#ifdef __cplusplus
390}
391#endif
392
393#endif /* GOEP_FS_H */