Fix checkwps by using host system's file IO (thanks to r25843/r25844) and by includin...
[kugel-rb.git] / firmware / include / file.h
blob1a43c6ad1dda085e69560aec6a2962201e4c343e
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 #ifdef __PCTOOL__
29 #include <fcntl.h>
30 #else
31 #include <sys/types.h>
32 #include "_ansi.h"
34 #define MAX_OPEN_FILES 11
36 #ifndef SEEK_SET
37 #define SEEK_SET 0
38 #endif
39 #ifndef SEEK_CUR
40 #define SEEK_CUR 1
41 #endif
42 #ifndef SEEK_END
43 #define SEEK_END 2
44 #endif
46 #ifndef O_RDONLY
47 #define O_RDONLY 0
48 #define O_WRONLY 1
49 #define O_RDWR 2
50 #define O_CREAT 4
51 #define O_APPEND 8
52 #define O_TRUNC 0x10
53 #endif
55 #if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC)
56 #define open(x, ...) sim_open(x, __VA_ARGS__)
57 #define creat(x,m) sim_creat(x,m)
58 #define remove(x) sim_remove(x)
59 #define rename(x,y) sim_rename(x,y)
60 #define filesize(x) sim_filesize(x)
61 #define fsync(x) sim_fsync(x)
62 #define ftruncate(x,y) sim_ftruncate(x,y)
63 #define lseek(x,y,z) sim_lseek(x,y,z)
64 #define read(x,y,z) sim_read(x,y,z)
65 #define write(x,y,z) sim_write(x,y,z)
66 #define close(x) sim_close(x)
67 extern int sim_creat(const char *pathname, mode_t mode);
68 extern int sim_open(const char *pathname, int flags, ...);
69 #endif
71 typedef int (*open_func)(const char* pathname, int flags, ...);
72 typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
73 typedef int (*creat_func)(const char *pathname, mode_t mode);
74 typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
75 typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
76 int(*_compar)(const void *, const void *));
78 extern int file_open(const char* pathname, int flags);
79 extern int close(int fd);
80 extern int fsync(int fd);
81 extern ssize_t read(int fd, void *buf, size_t count);
82 extern off_t lseek(int fildes, off_t offset, int whence);
83 extern int file_creat(const char *pathname);
84 #ifndef SIMULATOR
85 /* posix compatibility function */
86 static inline int creat(const char *pathname, mode_t mode)
88 (void)mode;
89 return file_creat(pathname);
91 #if !defined(CODEC) && !defined(PLUGIN)
92 #define open(x, y, ...) file_open(x,y)
93 #endif
94 #endif
95 extern ssize_t write(int fd, const void *buf, size_t count);
96 extern int remove(const char* pathname);
97 extern int rename(const char* path, const char* newname);
98 extern int ftruncate(int fd, off_t length);
99 extern off_t filesize(int fd);
100 extern int release_files(int volume);
101 int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
102 #endif
103 #endif