Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2002 by Björn Stenberg |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * 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 Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 16 | * |
| 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 Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 25 | #include <sys/types.h> |
| 26 | |
Daniel Stenberg | cc16624 | 2002-09-13 06:27:16 +0000 | [diff] [blame] | 27 | #undef MAX_PATH /* this avoids problems when building simulator */ |
Linus Nielsen Feltzing | 75447f6 | 2002-07-05 11:28:20 +0000 | [diff] [blame] | 28 | #define MAX_PATH 260 |
| 29 | |
Miika Pekkarinen | fcf8145 | 2007-02-25 19:01:32 +0000 | [diff] [blame] | 30 | #define MAX_OPEN_FILES 11 |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 31 | |
Daniel Stenberg | 2ec1e17 | 2002-08-02 12:33:48 +0000 | [diff] [blame] | 32 | #ifndef SEEK_SET |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 33 | #define SEEK_SET 0 |
Daniel Stenberg | 2ec1e17 | 2002-08-02 12:33:48 +0000 | [diff] [blame] | 34 | #endif |
| 35 | #ifndef SEEK_CUR |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 36 | #define SEEK_CUR 1 |
Daniel Stenberg | 2ec1e17 | 2002-08-02 12:33:48 +0000 | [diff] [blame] | 37 | #endif |
| 38 | #ifndef SEEK_END |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 39 | #define SEEK_END 2 |
Daniel Stenberg | 2ec1e17 | 2002-08-02 12:33:48 +0000 | [diff] [blame] | 40 | #endif |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 41 | |
Daniel Stenberg | 83e92b8 | 2002-05-05 10:32:59 +0000 | [diff] [blame] | 42 | #ifndef O_RDONLY |
Björn Stenberg | a98b20e | 2002-05-02 11:04:30 +0000 | [diff] [blame] | 43 | #define O_RDONLY 0 |
| 44 | #define O_WRONLY 1 |
| 45 | #define O_RDWR 2 |
Björn Stenberg | 4059ea6 | 2002-11-11 16:08:28 +0000 | [diff] [blame] | 46 | #define O_CREAT 4 |
| 47 | #define O_APPEND 8 |
| 48 | #define O_TRUNC 0x10 |
Daniel Stenberg | 83e92b8 | 2002-05-05 10:32:59 +0000 | [diff] [blame] | 49 | #endif |
Björn Stenberg | a98b20e | 2002-05-02 11:04:30 +0000 | [diff] [blame] | 50 | |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 51 | #ifdef SIMULATOR |
| 52 | #define open(x,y) sim_open(x,y) |
Jens Arnold | 67eb154 | 2007-02-01 23:08:15 +0000 | [diff] [blame] | 53 | #define creat(x) sim_creat(x) |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 54 | #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 Arnold | 399c081 | 2005-02-28 18:32:57 +0000 | [diff] [blame] | 59 | #define lseek(x,y,z) sim_lseek(x,y,z) |
Michael Sevakis | f64ebb1 | 2007-09-08 12:20:53 +0000 | [diff] [blame] | 60 | #define read(x,y,z) sim_read(x,y,z) |
| 61 | #define write(x,y,z) sim_write(x,y,z) |
Nicolas Pennequin | ef9abe4 | 2007-10-09 15:15:00 +0000 | [diff] [blame] | 62 | #define close(x) sim_close(x) |
Daniel Stenberg | ae960a9 | 2003-12-08 21:58:38 +0000 | [diff] [blame] | 63 | #endif |
| 64 | |
Daniel Stenberg | e15ac75 | 2003-12-09 06:48:10 +0000 | [diff] [blame] | 65 | typedef int (*open_func)(const char* pathname, int flags); |
| 66 | typedef ssize_t (*read_func)(int fd, void *buf, size_t count); |
Jens Arnold | 67eb154 | 2007-02-01 23:08:15 +0000 | [diff] [blame] | 67 | typedef int (*creat_func)(const char *pathname); |
Daniel Stenberg | e15ac75 | 2003-12-09 06:48:10 +0000 | [diff] [blame] | 68 | typedef ssize_t (*write_func)(int fd, const void *buf, size_t count); |
| 69 | typedef void (*qsort_func)(void *base, size_t nmemb, size_t size, |
| 70 | int(*_compar)(const void *, const void *)); |
| 71 | |
Björn Stenberg | b7b48fe | 2002-10-20 22:50:58 +0000 | [diff] [blame] | 72 | extern int open(const char* pathname, int flags); |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 73 | extern int close(int fd); |
Björn Stenberg | a4baacd | 2003-06-29 13:17:19 +0000 | [diff] [blame] | 74 | extern int fsync(int fd); |
Daniel Stenberg | ae960a9 | 2003-12-08 21:58:38 +0000 | [diff] [blame] | 75 | extern ssize_t read(int fd, void *buf, size_t count); |
| 76 | extern off_t lseek(int fildes, off_t offset, int whence); |
Jens Arnold | 67eb154 | 2007-02-01 23:08:15 +0000 | [diff] [blame] | 77 | extern int creat(const char *pathname); |
Daniel Stenberg | ae960a9 | 2003-12-08 21:58:38 +0000 | [diff] [blame] | 78 | extern ssize_t write(int fd, const void *buf, size_t count); |
Björn Stenberg | b7b48fe | 2002-10-20 22:50:58 +0000 | [diff] [blame] | 79 | extern int remove(const char* pathname); |
Björn Stenberg | c5f5be5 | 2002-11-19 12:48:50 +0000 | [diff] [blame] | 80 | extern int rename(const char* path, const char* newname); |
Daniel Stenberg | ae960a9 | 2003-12-08 21:58:38 +0000 | [diff] [blame] | 81 | extern int ftruncate(int fd, off_t length); |
Jean-Philippe Bernardy | cea551d | 2005-01-23 23:29:35 +0000 | [diff] [blame] | 82 | extern off_t filesize(int fd); |
Jörg Hohensohn | dc7534b | 2005-01-28 21:32:16 +0000 | [diff] [blame] | 83 | extern int release_files(int volume); |
Daniel Stenberg | 1beaa8b | 2002-08-05 07:51:09 +0000 | [diff] [blame] | 84 | |
Björn Stenberg | 0e2a5a6 | 2002-04-27 23:31:23 +0000 | [diff] [blame] | 85 | #endif |