Move c/h files implementing/defining standard library stuff into a new libc directory...
[kugel-rb.git] / firmware / include / file.h
blob2d5c9b88abda78fb82dc7958d9fa318e47e86595
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 #include <sys/types.h>
26 #include "_ansi.h"
28 #undef MAX_PATH /* this avoids problems when building simulator */
29 #define MAX_PATH 260
31 #define MAX_OPEN_FILES 11
33 #ifndef SEEK_SET
34 #define SEEK_SET 0
35 #endif
36 #ifndef SEEK_CUR
37 #define SEEK_CUR 1
38 #endif
39 #ifndef SEEK_END
40 #define SEEK_END 2
41 #endif
43 #ifndef O_RDONLY
44 #define O_RDONLY 0
45 #define O_WRONLY 1
46 #define O_RDWR 2
47 #define O_CREAT 4
48 #define O_APPEND 8
49 #define O_TRUNC 0x10
50 #endif
52 #if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC)
53 #define open(x, ...) sim_open(x, __VA_ARGS__)
54 #define creat(x,m) sim_creat(x,m)
55 #define remove(x) sim_remove(x)
56 #define rename(x,y) sim_rename(x,y)
57 #define filesize(x) sim_filesize(x)
58 #define fsync(x) sim_fsync(x)
59 #define ftruncate(x,y) sim_ftruncate(x,y)
60 #define lseek(x,y,z) sim_lseek(x,y,z)
61 #define read(x,y,z) sim_read(x,y,z)
62 #define write(x,y,z) sim_write(x,y,z)
63 #define close(x) sim_close(x)
64 extern int sim_creat(const char *pathname, mode_t mode);
65 extern int sim_open(const char *pathname, int flags, ...);
66 #endif
68 typedef int (*open_func)(const char* pathname, int flags, ...);
69 typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
70 typedef int (*creat_func)(const char *pathname, mode_t mode);
71 typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
72 typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
73 int(*_compar)(const void *, const void *));
75 extern int file_open(const char* pathname, int flags);
76 extern int close(int fd);
77 extern int fsync(int fd);
78 extern ssize_t read(int fd, void *buf, size_t count);
79 extern off_t lseek(int fildes, off_t offset, int whence);
80 extern int file_creat(const char *pathname);
81 #ifndef SIMULATOR
82 /* posix compatibility function */
83 static inline int creat(const char *pathname, mode_t mode)
85 (void)mode;
86 return file_creat(pathname);
88 #if !defined(CODEC) && !defined(PLUGIN)
89 #define open(x, y, ...) file_open(x,y)
90 #endif
91 #endif
92 extern ssize_t write(int fd, const void *buf, size_t count);
93 extern int remove(const char* pathname);
94 extern int rename(const char* path, const char* newname);
95 extern int ftruncate(int fd, off_t length);
96 extern off_t filesize(int fd);
97 extern int release_files(int volume);
98 int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
99 #endif