Convert many #ifdef SIMULATOR to #if (CONFIG_PLATFORM & PLATFORM_HOSTED) (and similar).
[kugel-rb.git] / firmware / include / file.h
blob9502f5999ac04f15aa71f1fd1ea7ba092afceb2b
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Björn Stenberg
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef _FILE_H_
23 #define _FILE_H_
25 #undef MAX_PATH /* this avoids problems when building simulator */
26 #define MAX_PATH 260
28 #include <sys/types.h>
29 #include "config.h"
30 #include "_ansi.h"
32 #define MAX_OPEN_FILES 11
34 #ifndef SEEK_SET
35 #define SEEK_SET 0
36 #endif
37 #ifndef SEEK_CUR
38 #define SEEK_CUR 1
39 #endif
40 #ifndef SEEK_END
41 #define SEEK_END 2
42 #endif
44 #ifndef O_RDONLY
45 #define O_RDONLY 0
46 #define O_WRONLY 1
47 #define O_RDWR 2
48 #define O_CREAT 4
49 #define O_APPEND 8
50 #define O_TRUNC 0x10
51 #endif
53 #if (CONFIG_PLATFORM & PLATFORM_HOSTED) && !defined(PLUGIN) && !defined(CODEC)
54 #define open(x, ...) sim_open(x, __VA_ARGS__)
55 #define creat(x,m) sim_creat(x,m)
56 #define remove(x) sim_remove(x)
57 #define rename(x,y) sim_rename(x,y)
58 #define filesize(x) sim_filesize(x)
59 #define fsync(x) sim_fsync(x)
60 #define ftruncate(x,y) sim_ftruncate(x,y)
61 #define lseek(x,y,z) sim_lseek(x,y,z)
62 #define read(x,y,z) sim_read(x,y,z)
63 #define write(x,y,z) sim_write(x,y,z)
64 #define close(x) sim_close(x)
65 extern int sim_creat(const char *pathname, mode_t mode);
66 extern int sim_open(const char *pathname, int flags, ...);
67 #endif
69 typedef int (*open_func)(const char* pathname, int flags, ...);
70 typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
71 typedef int (*creat_func)(const char *pathname, mode_t mode);
72 typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
73 typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
74 int(*_compar)(const void *, const void *));
76 extern int file_open(const char* pathname, int flags);
77 extern int close(int fd);
78 extern int fsync(int fd);
79 extern ssize_t read(int fd, void *buf, size_t count);
80 extern off_t lseek(int fildes, off_t offset, int whence);
81 extern int file_creat(const char *pathname);
82 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
83 /* posix compatibility function */
84 static inline int creat(const char *pathname, mode_t mode)
86 (void)mode;
87 return file_creat(pathname);
89 #if !defined(CODEC) && !defined(PLUGIN) && !defined(__PCTOOL__)
90 #define open(x, y, ...) file_open(x,y)
91 #endif
92 #endif
93 extern ssize_t write(int fd, const void *buf, size_t count);
94 extern int remove(const char* pathname);
95 extern int rename(const char* path, const char* newname);
96 extern int ftruncate(int fd, off_t length);
97 extern off_t filesize(int fd);
98 extern int release_files(int volume);
99 int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
100 #endif