blob: 3e07fd00c8fa0efc12c1265d631341243001c012 [file] [log] [blame]
Björn Stenberg0e2a5a62002-04-27 23:31:23 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000010 * Copyright (C) 2002 by Björn Stenberg
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _FILE_H_
23#define _FILE_H_
24
Daniel Stenberg22b77012005-02-22 12:19:12 +000025#include <sys/types.h>
26
Daniel Stenbergcc166242002-09-13 06:27:16 +000027#undef MAX_PATH /* this avoids problems when building simulator */
Linus Nielsen Feltzing75447f62002-07-05 11:28:20 +000028#define MAX_PATH 260
29
Miika Pekkarinenfcf81452007-02-25 19:01:32 +000030#define MAX_OPEN_FILES 11
Miika Pekkarinenab78b042005-10-07 17:38:05 +000031
Daniel Stenberg2ec1e172002-08-02 12:33:48 +000032#ifndef SEEK_SET
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000033#define SEEK_SET 0
Daniel Stenberg2ec1e172002-08-02 12:33:48 +000034#endif
35#ifndef SEEK_CUR
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000036#define SEEK_CUR 1
Daniel Stenberg2ec1e172002-08-02 12:33:48 +000037#endif
38#ifndef SEEK_END
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000039#define SEEK_END 2
Daniel Stenberg2ec1e172002-08-02 12:33:48 +000040#endif
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000041
Daniel Stenberg83e92b82002-05-05 10:32:59 +000042#ifndef O_RDONLY
Björn Stenberga98b20e2002-05-02 11:04:30 +000043#define O_RDONLY 0
44#define O_WRONLY 1
45#define O_RDWR 2
Björn Stenberg4059ea62002-11-11 16:08:28 +000046#define O_CREAT 4
47#define O_APPEND 8
48#define O_TRUNC 0x10
Daniel Stenberg83e92b82002-05-05 10:32:59 +000049#endif
Björn Stenberga98b20e2002-05-02 11:04:30 +000050
Daniel Stenberg22b77012005-02-22 12:19:12 +000051#ifdef SIMULATOR
52#define open(x,y) sim_open(x,y)
Jens Arnold67eb1542007-02-01 23:08:15 +000053#define creat(x) sim_creat(x)
Daniel Stenberg22b77012005-02-22 12:19:12 +000054#define remove(x) sim_remove(x)
55#define rename(x,y) sim_rename(x,y)
56#define filesize(x) sim_filesize(x)
57#define fsync(x) sim_fsync(x)
58#define ftruncate(x,y) sim_ftruncate(x,y)
Jens Arnold399c0812005-02-28 18:32:57 +000059#define lseek(x,y,z) sim_lseek(x,y,z)
Michael Sevakisf64ebb12007-09-08 12:20:53 +000060#define read(x,y,z) sim_read(x,y,z)
61#define write(x,y,z) sim_write(x,y,z)
Nicolas Pennequinef9abe42007-10-09 15:15:00 +000062#define close(x) sim_close(x)
Daniel Stenbergae960a92003-12-08 21:58:38 +000063#endif
64
Daniel Stenberge15ac752003-12-09 06:48:10 +000065typedef int (*open_func)(const char* pathname, int flags);
66typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
Jens Arnold67eb1542007-02-01 23:08:15 +000067typedef int (*creat_func)(const char *pathname);
Daniel Stenberge15ac752003-12-09 06:48:10 +000068typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
69typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
70 int(*_compar)(const void *, const void *));
71
Björn Stenbergb7b48fe2002-10-20 22:50:58 +000072extern int open(const char* pathname, int flags);
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000073extern int close(int fd);
Björn Stenberga4baacd2003-06-29 13:17:19 +000074extern int fsync(int fd);
Daniel Stenbergae960a92003-12-08 21:58:38 +000075extern ssize_t read(int fd, void *buf, size_t count);
76extern off_t lseek(int fildes, off_t offset, int whence);
Jens Arnold67eb1542007-02-01 23:08:15 +000077extern int creat(const char *pathname);
Daniel Stenbergae960a92003-12-08 21:58:38 +000078extern ssize_t write(int fd, const void *buf, size_t count);
Björn Stenbergb7b48fe2002-10-20 22:50:58 +000079extern int remove(const char* pathname);
Björn Stenbergc5f5be52002-11-19 12:48:50 +000080extern int rename(const char* path, const char* newname);
Daniel Stenbergae960a92003-12-08 21:58:38 +000081extern int ftruncate(int fd, off_t length);
Jean-Philippe Bernardycea551d2005-01-23 23:29:35 +000082extern off_t filesize(int fd);
Jörg Hohensohndc7534b2005-01-28 21:32:16 +000083extern int release_files(int volume);
Daniel Stenberg1beaa8b2002-08-05 07:51:09 +000084
Björn Stenberg0e2a5a62002-04-27 23:31:23 +000085#endif